From c5ee0eeb393909e012f77b5d195f84b81345152b Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Tue, 10 Oct 2023 13:45:48 +0500 Subject: [PATCH] Split BackgroundWorkController --- ...undWork.cs => BackgroundWorkController.cs} | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) rename AsbCloudWebApi/Controllers/{BackgroundWork.cs => BackgroundWorkController.cs} (63%) diff --git a/AsbCloudWebApi/Controllers/BackgroundWork.cs b/AsbCloudWebApi/Controllers/BackgroundWorkController.cs similarity index 63% rename from AsbCloudWebApi/Controllers/BackgroundWork.cs rename to AsbCloudWebApi/Controllers/BackgroundWorkController.cs index 316d796e..65e7171b 100644 --- a/AsbCloudWebApi/Controllers/BackgroundWork.cs +++ b/AsbCloudWebApi/Controllers/BackgroundWorkController.cs @@ -9,17 +9,16 @@ namespace AsbCloudWebApi.Controllers [Route("api/[controller]")] [Authorize] [ApiController] - public class BackgroundWork : ControllerBase + public class BackgroundWorkController : ControllerBase { private readonly BackgroundWorker backgroundWorker; - public BackgroundWork(BackgroundWorker backgroundWorker) + public BackgroundWorkController(BackgroundWorker backgroundWorker) { this.backgroundWorker = backgroundWorker; } [HttpGet] - //[ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public IActionResult GetAll() { var result = new { @@ -30,5 +29,19 @@ namespace AsbCloudWebApi.Controllers }; return Ok(result); } + + [HttpGet("Current")] + public IActionResult GetCurrent() + { + var result = (BackgroundWorkDto?)backgroundWorker.CurrentWork; + return Ok(result); + } + + [HttpGet("Failed")] + public IActionResult GetFelled() + { + var result = backgroundWorker.WorkStore.Felled.Select(work => (BackgroundWorkDto)work); + return Ok(result); + } } }