Example #1
0
        public ActionResult <Status> PostAlertConfiguration([FromBody] TestData body)
        {
            _logger.LogInformation("weathertype endpoint called");
            try
            {
                if (body == null)
                {
                    _logger.LogError($"/api/v1/weathertype: body is null");

                    return(StatusCode(400, new Status {
                        Result = false, Message = "body is null"
                    }));
                }

                if (!string.IsNullOrEmpty(body.WeatherType))
                {
                    return(StatusCode(201, Sql.AddWeatherType(body)));
                }

                _logger.LogError($"/api/v1/weathertype: WeatherType missing from body");

                return(StatusCode(400, new Status {
                    Result = false, Message = "WeatherType missing from body"
                }));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode(500, new Status {
                    Result = false, Message = ex.Message
                }));
            }
        }