public ActionResult Edit(CategoryAddEditViewModel formData)
        {
            Category category = new Category()
            {
                Id   = formData.Id,
                Name = formData.Name
            };

            if (!category.Exists)
            {
                category.Update();
                return(RedirectToAction("display"));
            }
            else
            {
                string        message   = "An Error occured when trying to edit category.";
                List <string> solutions = new List <string>();
                solutions.Add("Category Already exists");
                ErrorHelp error = new ErrorHelp()
                {
                    Message   = message,
                    Solutions = solutions
                };

                return(View("_ErrorView", error));
            }
        }
        public ActionResult Edit(int id)
        {
            Category category = Category.GetById(id);
            CategoryAddEditViewModel model = new CategoryAddEditViewModel(category.Id, category.Name);

            return(View(model));
        }
        public ActionResult Add(CategoryAddEditViewModel categoryFormData)
        {
            Category category = new Category(categoryFormData.Name);

            if (!category.Exists)
            {
                category.Save();
                return(RedirectToAction("add"));
            }
            else
            {
                string        message   = "An Error occured when trying to add new category.";
                List <string> solutions = new List <string>();
                solutions.Add("Category Already exists");
                ErrorHelp error = new ErrorHelp()
                {
                    Message   = message,
                    Solutions = solutions
                };

                return(View("_ErrorView", error));
            }
        }
        public ActionResult Add()
        {
            CategoryAddEditViewModel model = new CategoryAddEditViewModel();

            return(View(model));
        }