Esempio n. 1
0
        public ActionResult Edit(CategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                Category category = new Category { Name = model.Name, CategoryId = model.Id };
                db.AddCategory(category);

                return RedirectToAction("Index", "Home");
            }

            return View(model);
        }
Esempio n. 2
0
        void IPortfolioDataSource.AddCategory(Category category)
        {
            if (category.CategoryId != 0)
            {
                var entry = Categories.Find(category.CategoryId);
                Entry<Category>(entry).CurrentValues.SetValues(category);

                SaveChanges();
                return;
            }

            Categories.Add(category);
            SaveChanges();
        }