public async Task InsertDetection(InsertDetection detection) { Response.IsSuccessful = true; // validate request values if (detection.WeatherId == 0 || detection.CameraId == 0) { Response.IsSuccessful = false; Response.ErrorMessage = "You Must provide WeatherId CameraId "; return; } Detection newDetection = new Detection() { DetectionId = 0, WeatherId = detection.WeatherId, CameraId = detection.CameraId, Date = DateTime.UtcNow, ImagePath = detection.ImagePath }; // insert detection if (!await detectionCRUDService.InsertDetection(newDetection)) { Response.IsSuccessful = false; Response.ErrorMessage = "Cannot Insert Detecion "; return; } }
public async Task <IActionResult> InsertDetection([FromBody] InsertDetection request) { DetectionLogic detectionLogic = new DetectionLogic(); await detectionLogic.InsertDetection(request); if (!detectionLogic.Response.IsSuccessful) { return(BadRequest(detectionLogic.Response.ErrorMessage)); } return(Ok("Success")); }