Ejemplo n.º 1
0
        public async Task <IActionResult> ValidateCreate([FromQuery] ValidateCreateInspectionResource resource)
        {
            try
            {
                var result = await service.ValidateOnCreate(resource.InspectorId, resource.InspectionDate);

                if (result)
                {
                    return(Ok(true));
                }

                throw new ApplicationException("Only one Inspection per Inspector and Day could be added.");
            }
            catch (ApplicationException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception)
            {
                return(BadRequest("An error was thrown while trying to validate inspection."));
            }
        }