public IHttpActionResult Post([FromBody] DTO.TripForCreation tripForCreation) { string ownerId = TokenIdentityHelper.GetOwnerIdFromToken(); using (var uow = new CreateTrip(ownerId)) { var uowResult = uow.Execute(tripForCreation); switch (uowResult.Status) { case UnitOfWork.UnitOfWorkStatus.Ok: return(Created <DTO.Trip> (Request.RequestUri + "/" + uowResult.Result.Id.ToString(), uowResult.Result)); case UnitOfWork.UnitOfWorkStatus.Forbidden: return(StatusCode(HttpStatusCode.Forbidden)); case UnitOfWork.UnitOfWorkStatus.Invalid: return(BadRequest()); default: return(InternalServerError()); } } }
public IHttpActionResult Post([FromBody] DTO.TripForCreation tripForCreation) { try { using (var uow = new CreateTrip(null)) { var uowResult = uow.Execute(tripForCreation); switch (uowResult.Status) { case UnitOfWork.UnitOfWorkStatus.Ok: return(Created <DTO.Trip> (Request.RequestUri + "/" + uowResult.Result.Id.ToString(), uowResult.Result)); case UnitOfWork.UnitOfWorkStatus.Invalid: return(BadRequest()); case UnitOfWork.UnitOfWorkStatus.Forbidden: return(StatusCode(HttpStatusCode.Forbidden)); default: return(InternalServerError()); } } } catch (Exception) { return(InternalServerError()); } }
public IHttpActionResult Post([FromBody]DTO.TripForCreation tripForCreation) { try { using (var uow = new CreateTrip(null)) { var uowResult = uow.Execute(tripForCreation); switch (uowResult.Status) { case UnitOfWork.UnitOfWorkStatus.Ok: return Created<DTO.Trip> (Request.RequestUri + "/" + uowResult.Result.Id.ToString(), uowResult.Result); case UnitOfWork.UnitOfWorkStatus.Invalid: return BadRequest(); case UnitOfWork.UnitOfWorkStatus.Forbidden: return StatusCode(HttpStatusCode.Forbidden); default: return InternalServerError(); } } } catch (Exception) { return InternalServerError(); } }