Esempio n. 1
0
 public ActionResult Delete(int Item)
 {
     // TODO: Move all items under this category to parent category
     using (var database = new DatabaseEntities())
     {
         var category = database.CategoryById(Item);
         if (category != null)
         {
             database.DeleteObject(category);
             database.SaveChanges();
         }
     }
     return RedirectToAction("Index");
 }
Esempio n. 2
0
 public ActionResult Add()
 {
     var viewModel = new AddCategoryViewModel();
     int parentId;
     if (Request.QueryString["parent"] != null &&
         int.TryParse(Request.QueryString["parent"], out parentId))
     {
         Category parent;
         using (var database = new DatabaseEntities())
         {
             parent = database.CategoryById(parentId);
         }
         if (parent != null)
         {
             viewModel.Parent = parentId;
             viewModel.ParentName = parent.Name;
         }
     }
     return View(viewModel);
 }
Esempio n. 3
0
 public ActionResult Rename(int Id, string NewName)
 {
     using (var database = new DatabaseEntities())
     {
         var category = database.CategoryById(Id);
         category.Name = NewName;
         database.SaveChanges();
     }
     return RedirectToAction("Index");
 }