public async Task <ActionResult> CreateTrip(TripViewModel model) { // create a new Trip object from the form and save it Trip trip = new Trip() { AspNetUserId = User.Identity.GetUserId(), DestinationId = model.CreateTripViewModel.DestinationId, NickName = model.CreateTripViewModel.NickName, StartDate = model.CreateTripViewModel.StartDate, StartLocation = model.CreateTripViewModel.StartLocation, Status = TripStatus.planned.ToString(), HomeLocation = model.CreateTripViewModel.HomeLocation, PaxAdults = model.CreateTripViewModel.Adults, PaxMinors = model.CreateTripViewModel.Minors, TripType = model.CreateTripViewModel.TripType, TripCurrency = model.CreateTripViewModel.Currency, }; var _blError = await TripManager.CreateTrip(trip, model.CreateTripViewModel.TemplateId); if (_blError.ErrorCode > 0) { throw new ApplicationException(_blError.ErrorMessage); } return(RedirectToAction("ViewTrip", new { tripId = trip.Id })); }
public async Task ShouldAddNewTrip() { var trip = new Trip { StartDate = DateTimeOffset.Now.AddDays(10), EndDate = DateTimeOffset.Now.AddDays(20), Comment = "Test Add", Destination = "France" }; int numTrips = Trips.Count; await TripManager.CreateTrip(trip); Assert.That(trip, Is.EqualTo(Trips[trip.Id])); Assert.That(Trips.Count, Is.EqualTo(numTrips + 1)); var unused = Uow.Received(1).CommitAsync(); }