From a510abd7f7f3c7f000edc3ddb87cb27ce4a5fcf1 Mon Sep 17 00:00:00 2001 From: Tara Wilson Date: Mon, 2 Dec 2024 20:52:16 -0500 Subject: [PATCH] Adding external connection to mongo Adding endpoints Updating rest files --- .../api/Controllers/EventController.cs | 18 +++++++++++++++--- .../api/Controllers/TicketController.cs | 3 ++- source/ticketAPI/api/RestFiles/event.http | 10 ++++++++-- source/ticketAPI/api/RestFiles/ticket.http | 3 ++- source/ticketAPI/api/Services/TicketManager.cs | 1 + .../ticketAPI/api/appsettings.Development.json | 2 +- source/ticketAPI/api/appsettings.json | 2 +- .../Request/{MintTickets.cs => AddTicket.cs} | 2 +- 8 files changed, 31 insertions(+), 10 deletions(-) rename source/ticketAPI/models/Request/{MintTickets.cs => AddTicket.cs} (83%) diff --git a/source/ticketAPI/api/Controllers/EventController.cs b/source/ticketAPI/api/Controllers/EventController.cs index 6f01234..7261e1e 100644 --- a/source/ticketAPI/api/Controllers/EventController.cs +++ b/source/ticketAPI/api/Controllers/EventController.cs @@ -1,5 +1,6 @@ using api.Interfaces; using Microsoft.AspNetCore.Mvc; +using models.Core; using models.Request; namespace api.Controllers; @@ -7,7 +8,7 @@ namespace api.Controllers; /// /// Endpoints for Event Management /// -/// +/// Event Manager Service [ApiController] [Route("[controller]")] public class EventController(IEventManager eventManager) : ControllerBase @@ -28,6 +29,11 @@ public class EventController(IEventManager eventManager) : ControllerBase } } + /// + /// Updates an Event + /// + /// New Event Information + /// [HttpPatch] public ActionResult Patch([FromBody] PatchEvent request) { @@ -44,8 +50,14 @@ public class EventController(IEventManager eventManager) : ControllerBase } } - [HttpGet("{startDate}/{endDate}")] - public ActionResult Get([FromRoute] DateTime startDate, DateTime endDate) + /// + /// Gets a list of all events between a start date and an end date + /// + /// Start date for the event search + /// End date for the event search + /// + [HttpGet] + public ActionResult> Get(DateTime startDate, DateTime endDate) { try { diff --git a/source/ticketAPI/api/Controllers/TicketController.cs b/source/ticketAPI/api/Controllers/TicketController.cs index 5c1249c..df1fec6 100644 --- a/source/ticketAPI/api/Controllers/TicketController.cs +++ b/source/ticketAPI/api/Controllers/TicketController.cs @@ -22,7 +22,7 @@ public class TicketController( /// /// Base64 String Qr Code [HttpPost] - public ActionResult AddTicket([FromBody] MintTickets mintRequest) + public ActionResult Post([FromBody] AddTicket mintRequest) { //TODO: Protect Endpoint @@ -40,6 +40,7 @@ public class TicketController( Id = ticketId, QrCode = qrCode, Type = mintRequest.Type, + EventId = mintRequest.EventId }; //save the minted ticket diff --git a/source/ticketAPI/api/RestFiles/event.http b/source/ticketAPI/api/RestFiles/event.http index cadb4ba..4a97ac9 100644 --- a/source/ticketAPI/api/RestFiles/event.http +++ b/source/ticketAPI/api/RestFiles/event.http @@ -25,7 +25,7 @@ Content-Type: application/json ### -PATCH {{api_HostAddress}}/Event +PATCH {{api_HostAddress}}/event Accept: application/json Content-Type: application/json @@ -47,4 +47,10 @@ Content-Type: application/json "Name": "Parma Symphony Orchestra", "Description": "Parma Symphony Orchestra is a Northeast Ohio community orchestra with over 50 years of history bringing classical music to people of all ages, with opportunities for local students and professional guests to perform a wide ranging repertoire." } -} \ No newline at end of file +} + +### + +GET {{api_HostAddress}}/event?startDate=2024-12-01&endDate=2024-12-31 +Accept: application/json +Content-Type: application/json \ No newline at end of file diff --git a/source/ticketAPI/api/RestFiles/ticket.http b/source/ticketAPI/api/RestFiles/ticket.http index 4510c18..d8173d1 100644 --- a/source/ticketAPI/api/RestFiles/ticket.http +++ b/source/ticketAPI/api/RestFiles/ticket.http @@ -5,7 +5,8 @@ Accept: application/json Content-Type: application/json { - "ticketType": "Single" + "ticketType": "Single", + "eventId": "1a06c032-b073-4715-9b95-9f3410e7abd9" } ### diff --git a/source/ticketAPI/api/Services/TicketManager.cs b/source/ticketAPI/api/Services/TicketManager.cs index 3e8036e..ddaa6fe 100644 --- a/source/ticketAPI/api/Services/TicketManager.cs +++ b/source/ticketAPI/api/Services/TicketManager.cs @@ -8,6 +8,7 @@ public class TicketManager : ITicketManager { public void SaveMintedTicket(Ticket ticket) { + //TODO: Add Ticket to Event new Save().Execute(ticket); } } \ No newline at end of file diff --git a/source/ticketAPI/api/appsettings.Development.json b/source/ticketAPI/api/appsettings.Development.json index f82d217..d41ebb0 100644 --- a/source/ticketAPI/api/appsettings.Development.json +++ b/source/ticketAPI/api/appsettings.Development.json @@ -6,7 +6,7 @@ } }, "Mongo": { - "ConnectionString": "mongodb://terralilly85:pr1ncessN0ra@192.168.1.14:27017/", + "ConnectionString": "mongodb://terralilly85:pr1ncessN0ra@www.taraformed.com:27017/", "Database": "pso" } } diff --git a/source/ticketAPI/api/appsettings.json b/source/ticketAPI/api/appsettings.json index d95b08f..f3a75b5 100644 --- a/source/ticketAPI/api/appsettings.json +++ b/source/ticketAPI/api/appsettings.json @@ -6,7 +6,7 @@ } }, "Mongo": { - "ConnectionString": "mongodb://terralilly85:pr1ncessN0ra@192.168.1.14:27017/", + "ConnectionString": "mongodb://terralilly85:pr1ncessN0ra@www.taraformed.com:27017/", "Database": "pso" }, "AllowedHosts": "*" diff --git a/source/ticketAPI/models/Request/MintTickets.cs b/source/ticketAPI/models/Request/AddTicket.cs similarity index 83% rename from source/ticketAPI/models/Request/MintTickets.cs rename to source/ticketAPI/models/Request/AddTicket.cs index d560ff8..0ccccb2 100644 --- a/source/ticketAPI/models/Request/MintTickets.cs +++ b/source/ticketAPI/models/Request/AddTicket.cs @@ -2,7 +2,7 @@ using models.Enumerations; namespace models.Request; -public class MintTickets +public class AddTicket { public TicketType Type { get; set; } public Guid EventId { get; set; }