public APISuccessResponse AddRectangle([FromBody] RectangleArea rectangle) { try { if (rectangle.Coordinate1.Longitude == rectangle.Coordinate2.Longitude || rectangle.Coordinate1.Latitude == rectangle.Coordinate2.Latitude) { HttpContext.Response.StatusCode = BadRequest().StatusCode; return(new APISuccessResponse("The selected shape is not a rectangle")); } bool isSuccess = _GPSService.AddRectangle(rectangle); if (isSuccess) { HttpContext.Response.StatusCode = Ok().StatusCode; return(new APISuccessResponse()); } else { return(new APISuccessResponse("Error in adding rectangle 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")); } }