예제 #1
0
        public ActionResult Edit(DepartureEdit departureEdit)
        {
            if (_departureQueryService.IsCodeUnique(departureEdit.Code, departureEdit.ProductId))
            {
                ModelState.AddModelError("Code", "Departure code must be unique");
            }
            if (!ModelState.IsValid)
            {
                departureEdit.OrganizationList       = _organizationService.Organizations();
                departureEdit.OrganizationModel      = new System.Collections.Generic.List <string>();
                departureEdit.AvailabilityStatusList = _tourQueryService.Availabilities();
                return(View(departureEdit));
            }

            departureEdit.SelectedOrganizations = new System.Collections.Generic.List <int>();
            foreach (string s in departureEdit.OrganizationModel)
            {
                departureEdit.SelectedOrganizations.Add(Convert.ToInt32(s));
            }

            var departureUpdate = Mapper.Map <DepartureUpdate>(departureEdit);

            _departureCommandService.Update(departureUpdate);
            TempData["Info"] = "Departure updated.";
            return(RedirectToRoute("admin-departure-edit", new { productId = departureEdit.ProductId }));
        }
예제 #2
0
        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));
        }