public IActionResult CreateGym(GymDto dto) { Log.Information("Attempting to create gym."); Gym g = _GymService.CreateGym(dto); if (g == null) { Log.Error("Failed to create gym."); return(BadRequest()); } else { Log.Information("Gym created successfully."); return(Created("Gym created successfully.", g)); } }
public IHttpActionResult PostGym(Gym gym) { if (!ModelState.IsValid) { return(ResponseMessage(Request.CreateResponse( HttpStatusCode.BadRequest, ModelState.GetErrorStrings()))); } try { _gymService.CreateGym(gym); //return CreatedAtRoute("DefaultApi", new { id = order.OrderID }, order); return(Ok(gym)); } catch (DbUpdateException ex) { return(BadRequest(ex.GetBaseException().Message)); } }