Ejemplo n.º 1
0
        public ActionResult Insert(CategoryEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var result = ProductRepository.InsertCategory(model.Name, model.SeqNo, model.Description, model.Properties,
                                                           model.ParentCategoryId, SessionManager.Admin.UserId);

                if (result.Result)
                    return RedirectToAction("index", "category");

                ModelState.AddModelError("",result.Message);

            }
            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(CategoryEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var result = ProductRepository.UpdateCategory(model.CategoryId, model.Name,
                                                              model.SeqNo, model.Description, model.Properties,
                                                              model.ParentCategoryId, SessionManager.Admin.UserId);

                if (result.Result)
                    return RedirectToAction("index", "category", new {area = "manager"});
                ModelState.AddModelError("", result.Message);

            }
            if (model.Properties ==null)
                model.Properties = new List<PropertyCategoryModel>();

            return View(model);
        }
Ejemplo n.º 3
0
        public ActionResult Edit(string id)
        {
            var category = ProductRepository.GetAllCategory();

            var editCategory = ProductRepository.GetCategoryById(id);

            if (editCategory == null)
                return RedirectToAction("index", "category", new {area = "manager"});

            var model = new CategoryEditViewModel()
                {
                    CategoryId = editCategory.CategoryId,
                    Properties = editCategory.Properties,
                    Name = editCategory.Name,
                    CategoryParent = category,
                    Description = editCategory.Description,
                    ParentCategoryId = editCategory.ParentCategoryId,
                    SeqNo = editCategory.SeqNo
                };

            return View(model);
        }