public ActionResult Create(int tourId) { var tour = _tourQueryService.FindTour(tourId); var departureEdit = new DepartureEdit { TourId = tourId, TourName = tour.Name, TourPermalink = tour.Permalink, AvailabilityStatusList = _tourQueryService.Availabilities(), OrganizationList = _organizationService.Organizations(), OrganizationModel = new System.Collections.Generic.List<string>() }; return View(departureEdit); }
public ActionResult Create(DepartureEdit departureEdit) { if (_departureQueryService.IsCodeUnique(departureEdit.Code)) ModelState.AddModelError("Code", "Departure code must be unique"); departureEdit.SelectedOrganizations = new System.Collections.Generic.List<int>(); foreach (string s in departureEdit.OrganizationModel) departureEdit.SelectedOrganizations.Add(Convert.ToInt32(s)); if (ModelState.IsValid) { var departureUpdate = Mapper.Map<DepartureUpdate>(departureEdit); var departure = _departureCommandService.Add(departureUpdate); return RedirectToRoute("admin-departure-edit", new { productId = departure.ProductId }); } if (departureEdit.OrganizationModel == null) departureEdit.OrganizationModel = new System.Collections.Generic.List<string>(); departureEdit.OrganizationList = _organizationService.Organizations(); departureEdit.AvailabilityStatusList = _tourQueryService.Availabilities(); return View(departureEdit); }