public ActionResult Create()
 {
     var subCategoryEdit = new SubCategoryEdit
     {
         CategoryList = _subcategoryQueryService.Categories(),
         TourList = _subcategoryQueryService.Tours(),
         TourFromPost = new System.Collections.Generic.List<string>()
     };
     return View(subCategoryEdit);
 }
        public ActionResult Create(SubCategoryEdit subCategoryEdit)
        {
            if (_subcategoryQueryService.IsCodeUnique(subCategoryEdit.Code))
                ModelState.AddModelError("Code", "Tour code must be unique");
            subCategoryEdit.SelectedTours = new System.Collections.Generic.List<int>();
            foreach (string s in subCategoryEdit.TourFromPost)
                subCategoryEdit.SelectedTours.Add(Convert.ToInt32(s));
            if (ModelState.IsValid)
            {
                var tourUpdate = Mapper.Map<SubCategoryUpdate>(subCategoryEdit);
                _subcategoryCommandService.Add(tourUpdate);
                return RedirectToRoute("admin-Sub-categories");
            }
            if (subCategoryEdit.TourFromPost == null)
                subCategoryEdit.TourFromPost = new System.Collections.Generic.List<string>();

            subCategoryEdit.CategoryList = _subcategoryQueryService.Categories();
            subCategoryEdit.TourList = _subcategoryQueryService.Tours();
            return View(subCategoryEdit);
        }
        public ActionResult Edit(SubCategoryEdit subcategoryedit)
        {
            if (_subcategoryQueryService.IsCodeUnique(subcategoryedit.Code, subcategoryedit.Id))
                ModelState.AddModelError("Code", "Tour code must be unique");

            if (!ModelState.IsValid)
            {

                subcategoryedit.CategoryList = _subcategoryQueryService.Categories();
                subcategoryedit.TourList = _subcategoryQueryService.Tours();
                subcategoryedit.TourFromPost = new System.Collections.Generic.List<string>();
                return View(subcategoryedit);
            }

            subcategoryedit.SelectedTours = new System.Collections.Generic.List<int>();
            foreach (string s in subcategoryedit.TourFromPost)
                subcategoryedit.SelectedTours.Add(Convert.ToInt32(s));

            var subcategoryUpdate = Mapper.Map<SubCategoryUpdate>(subcategoryedit);
            _subcategoryCommandService.Update(subcategoryUpdate);
            TempData["Info"] = "Sub Category updated";
            return RedirectToRoute("admin-sub-category-edit", new { subcategoryedit.Id });
        }