Expose error message using ProducesResponseType

This commit is contained in:
2024-06-18 13:36:30 -07:00
parent e7b721fdb3
commit fe3292133e
4 changed files with 50 additions and 24 deletions

View File

@ -12,7 +12,16 @@ public class WaferCounterController : Controller, IWaferCounterController<IActio
public WaferCounterController(IWaferCounterRepository waferCounterRepository) =>
_WaferCounterRepository = waferCounterRepository;
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[HttpGet("{waferSize}/last-quantity-and-slot-map")]
public IActionResult GetLastQuantityAndSlotMap(string area, string waferSize) =>
Json(_WaferCounterRepository.GetLastQuantityAndSlotMap(area, waferSize));
public IActionResult GetLastQuantityAndSlotMap(string area, string waferSize)
{
Shared.DataModels.WaferCounter? waferCounter = _WaferCounterRepository.GetLastQuantityAndSlotMap(area, waferSize);
if (waferCounter is null)
return this.BadRequest();
else if (!string.IsNullOrEmpty(waferCounter.Message))
return this.BadRequest(waferCounter.Message);
else
return Json(waferCounter);
}
}