From bc3bd21eb248c05fef1687c101092687460744ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Tue, 26 Dec 2023 11:42:51 +0100 Subject: [PATCH] Get layer by number --- WebAPI/Controllers/LayersController.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/WebAPI/Controllers/LayersController.cs b/WebAPI/Controllers/LayersController.cs index 4692820..e38baff 100644 --- a/WebAPI/Controllers/LayersController.cs +++ b/WebAPI/Controllers/LayersController.cs @@ -78,8 +78,7 @@ namespace WebAPI.Controllers } } [HttpGet] - [Route("{id}")] - public IActionResult Get(Guid id) + [Route("{id}")] public IActionResult Get(Guid id) { try { @@ -94,6 +93,26 @@ namespace WebAPI.Controllers } } [HttpGet] + [Route("getByNumber/{apiKey}/{number}")] + public IActionResult GetByNumber(string apiKey, int number) + { + if (apiKey != configuration["apiKey"]) + { + return Unauthorized(); + } + try + { + return Ok(db.Layers + .Include(x => x.CreatedBy) + .Include(x => x.Records) + .Where(x => x.Number == number && !x.IsDeleted).First()); + } + catch (Exception e) + { + return BadRequest(e.ToString()); + } + } + [HttpGet] [Route("exportToGoogleSheet/{id}")] public IActionResult ExportToGoogleSheet(Guid id) {