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());
                }
            }
        }
Example #2
0
        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());
            }
        }
Example #3
0
        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();
            }
        }