From 28a27472a831f3497dbed69f528577141daa7afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Thu, 7 Jan 2021 16:56:49 +0100 Subject: [PATCH 1/2] SES-130 Add Controler for other equipment and endpoint that returns it --- .../Controllers/OtherEquipmentController.cs | 28 +++++++++++++++++++ .../SessionCompanion/SessionCompanion.csproj | 4 --- .../SessionCompanion/SessionCompanion.xml | 6 ++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 SessionCompanion/SessionCompanion/Controllers/OtherEquipmentController.cs diff --git a/SessionCompanion/SessionCompanion/Controllers/OtherEquipmentController.cs b/SessionCompanion/SessionCompanion/Controllers/OtherEquipmentController.cs new file mode 100644 index 0000000..893836f --- /dev/null +++ b/SessionCompanion/SessionCompanion/Controllers/OtherEquipmentController.cs @@ -0,0 +1,28 @@ +using Microsoft.AspNetCore.Mvc; +using SessionCompanion.Services.Interfaces; +using SessionCompanion.ViewModels.OtherEquipmentViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SessionCompanion.Controllers +{ + [Route("api/otherEquipment")] + [ApiController] + public class OtherEquipmentController : Controller + { + private readonly IOtherEquipmentService _service; + public OtherEquipmentController(IOtherEquipmentService service) => _service = service; + + /// + /// Metoda zwraca wszystkie dostępne inne przedmioty + /// + /// Lista wszystkich innych przedmiotów w bazie danych + [HttpGet("getAllOtherEquipment")] + public async Task> GetOtherEquipment() + { + return _service.Get().ToList(); + } + } +} diff --git a/SessionCompanion/SessionCompanion/SessionCompanion.csproj b/SessionCompanion/SessionCompanion/SessionCompanion.csproj index c455a8f..f0f585f 100644 --- a/SessionCompanion/SessionCompanion/SessionCompanion.csproj +++ b/SessionCompanion/SessionCompanion/SessionCompanion.csproj @@ -36,10 +36,6 @@ - - - - diff --git a/SessionCompanion/SessionCompanion/SessionCompanion.xml b/SessionCompanion/SessionCompanion/SessionCompanion.xml index b96a03b..0462a94 100644 --- a/SessionCompanion/SessionCompanion/SessionCompanion.xml +++ b/SessionCompanion/SessionCompanion/SessionCompanion.xml @@ -31,6 +31,12 @@ Id postaci Listę wszystkich statystyk + + + Metoda zwraca wszystkie dostępne inne przedmioty + + Lista wszystkich innych przedmiotów w bazie danych + Metoda przyjmuje login oraz hasło i sprawdza czy istnieje użytkownik o podanych parametrach -- 2.20.1 From 6c3e23a1ea273e847805bedb43d496537693b1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Fri, 8 Jan 2021 17:47:43 +0100 Subject: [PATCH 2/2] SES-131 Add Error Reponse --- .../Controllers/OtherEquipmentController.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/SessionCompanion/SessionCompanion/Controllers/OtherEquipmentController.cs b/SessionCompanion/SessionCompanion/Controllers/OtherEquipmentController.cs index 893836f..d21d202 100644 --- a/SessionCompanion/SessionCompanion/Controllers/OtherEquipmentController.cs +++ b/SessionCompanion/SessionCompanion/Controllers/OtherEquipmentController.cs @@ -1,5 +1,7 @@ using Microsoft.AspNetCore.Mvc; +using SessionCompanion.Extensions.EitherType; using SessionCompanion.Services.Interfaces; +using SessionCompanion.ViewModels.ApiResponses; using SessionCompanion.ViewModels.OtherEquipmentViewModels; using System; using System.Collections.Generic; @@ -20,9 +22,21 @@ namespace SessionCompanion.Controllers /// /// Lista wszystkich innych przedmiotów w bazie danych [HttpGet("getAllOtherEquipment")] - public async Task> GetOtherEquipment() + public async Task, ErrorResponse>> GetOtherEquipment() { - return _service.Get().ToList(); + try + { + var otherEq = _service.Get().ToList(); + return otherEq; + } + catch (Exception e) + { + return new ErrorResponse() + { + StatusCode = 204, + Message = e.Message + }; + } } } } -- 2.20.1