public ActionResult CreateCategory(InputCategoryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                TempData["NotificationError"] = "Something is wrong, please try again later";
                return(View(model));
            }

            var category = Mapper.Map <Category>(model);

            m_Categories.CreateCategory(category);
            TempData["Notification"] = "You successfully add category";

            return(RedirectToAction("Index"));
        }
        public ActionResult CreateCategory(InputCategoryViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                this.TempData["NotificationError"] = "Something is wrong, please try again later";
                return this.View(model);
            }

            var category = this.Mapper.Map<Category>(model);

            this.categories.CreateCategory(category);
            this.TempData["Notification"] = "You successfully add category";

            return this.RedirectToAction("Index");
        }
Example #3
0
        public ActionResult Delete(InputCategoryViewModel input)
        {
            this.categories.Delete(input.Id.ToString());

            return(this.RedirectToAction("/Edit"));
        }
Example #4
0
        public ActionResult Create(InputCategoryViewModel input)
        {
            var newCategory = this.categories.Create(input.Name);

            return(this.RedirectToAction("/Edit"));
        }
Example #5
0
        public ActionResult Edit(InputCategoryViewModel input)
        {
            var category = this.categories.Update(input.Id.ToString(), input.Name);

            return(this.RedirectToAction("/Edit"));
        }