Example #1
0
        public virtual ActionResult Create( Category category )
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.ParentId = new SelectList(db.Categories, "Id", "Name", category.ParentId);
            return View(category);
        }
Example #2
0
 public virtual ActionResult Edit( Category category )
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         ExpenseEntitiesCache.RefreshCategories(MvcExpenseFactory.NewUnitOfWork());
         return RedirectToAction("Index");
     }
     ViewBag.ParentId = new SelectList(db.Categories, "Id", "Name", category.ParentId);
     return View(category);
 }