Exemplo n.º 1
0
        public async Task <CommandResult <Guid> > CreateTrip([FromBody] CreateTripViewModel viewModel)
        {
            var createTripModel = _mapper.Map <WebSiteTripModel>(viewModel);
            var result          = await _tripManager.CreateTrip(createTripModel);

            if (result.IsSucceeded)
            {
                foreach (var image in viewModel.Images)
                {
                    this.ConfirmImageAdded(image);
                    this.ConfirmFileAdded(image);
                }
                if (!string.IsNullOrEmpty(viewModel.PdfName))
                {
                    this.ConfirmFileAdded(viewModel.PdfName);
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> Post(Trip trip)
        {
            var tripEntity = new Data.Trip
            {
                UserId      = User.Identity.GetUserId(),
                Comment     = trip.Comment,
                Destination = trip.Destination,
                EndDate     = trip.EndDate,
                StartDate   = trip.StartDate,
            };
            await _tripManager.CreateTrip(tripEntity);

            return(Created(new Uri(string.Format("/trips/{0}", tripEntity.Id), UriKind.Relative), new TripWithId
            {
                Id = tripEntity.Id,
                StartDate = tripEntity.StartDate,
                EndDate = tripEntity.EndDate,
                Destination = tripEntity.Destination,
                Comment = tripEntity.Comment
            }));
        }