Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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 }));
        }
Exemplo n.º 3
0
        public SubCategory EditSubCat(SubCategoryEdit item)
        {
            SubCategory var = CurrentDbContext.SubCategoryDB.Include("Category").SingleOrDefault(s => s.StringId == item.StringId);

            var.Name    = item.Name;
            var.SeoName = SeoManager.GetSeoCategory(var.Category.Name, var.Name);
            CurrentDbContext.SaveChanges();

            return(var);
        }
Exemplo n.º 4
0
        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 SubCategoryEdit(SubCategoryEdit edititem)
        {
            if (!ModelState.IsValid)
            {
                return(View(edititem));
            }

            var addedItem = AdminManager.EditSubCat(edititem);

            if (addedItem == null)
            {
                return(View(edititem));
            }
            else
            {
                CacheHelper.RemoveFromCache(string.Format("getcatlist-{0}", addedItem.Id));
                CacheHelper.RemoveFromCache("getnavibarcatlist");
                return(RedirectToAction("CategoryDetails", new { id = edititem.CategoryId }));
            }
        }