コード例 #1
0
 public ActionResult Edit(MenuCategory menuCategory)
 {
     if (ModelState.IsValid)
     {
         menuRepository.SaveMenuCategory(menuCategory);
         TempData["message"] = MessageHelper.BuildMessage(EnumSevereLevel.Success, string.Format("{0} has been created!", menuCategory.MenuCategoryName));
         return RedirectToAction("List");
     }
     else
     {
         //There is something wrong with the data values
         TempData["message"] = MessageHelper.BuildMessage(EnumSevereLevel.Error, "There is something wrong with the data values, please check!");
         return View(menuCategory);
     }
 }
コード例 #2
0
 public void SaveMenuCategory(MenuCategory menuCategory)
 {
     if (menuCategory.MenuCategoryId == 0)
     {
         context.MenuCategories.Add(menuCategory);
     }
     else
     {
         MenuCategory dbEntry = context.MenuCategories.Find(menuCategory.MenuCategoryId);
         if (dbEntry != null)
         {
             dbEntry.MenuCategoryName = menuCategory.MenuCategoryName;
             dbEntry.Sequence = menuCategory.Sequence;
         }
     }
     context.SaveChanges();
 }
コード例 #3
0
 public SelectMenuCategoryEditorViewModel(MenuCategory category)
 {
     this.MenuCategoryId = category.MenuCategoryId;
     this.MenuCategoryName = category.MenuCategoryName;
 }