Ejemplo n.º 1
0
        public APISuccessResponse AddCircle([FromBody] CircleArea circle)
        {
            try
            {
                if (circle.Radius == 0 || string.IsNullOrEmpty(circle.Name))
                {
                    HttpContext.Response.StatusCode = BadRequest().StatusCode;

                    return(new APISuccessResponse("One or more fields in the request contain invalid data"));
                }

                bool isSuccess = _GPSService.AddCircle(circle);

                if (isSuccess)
                {
                    HttpContext.Response.StatusCode = Ok().StatusCode;

                    return(new APISuccessResponse());
                }
                else
                {
                    return(new APISuccessResponse("Error in adding circle to database"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogWarning("An error occurs, Exception: {Exception Message}", ex.Message);
                HttpContext.Response.StatusCode = 500;

                return(new APISuccessResponse("Internal Server Error"));
            }
        }