예제 #1
0
 public ActionResult Edit(PageBinding pageBinding)
 {
     if (ModelState.IsValid)
     {
         menuRepository.SavePageBinding(pageBinding);
         TempData["message"] = MessageHelper.BuildMessage(EnumSevereLevel.Success, string.Format("{0} has been created!", pageBinding.PageTitle));
         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!");
         ViewBag.MenuCategories = menuRepository.MenuCategories;
         ViewBag.Menus = menuRepository.Menus;
         return View(pageBinding);
     }
 }
예제 #2
0
 public void SavePageBinding(PageBinding pageBinding)
 {
     if (pageBinding.PageBindingId == 0)
     {
         context.PageBindings.Add(pageBinding);
     }
     else
     {
         PageBinding dbEntry = context.PageBindings.Find(pageBinding.PageBindingId);
         if (dbEntry != null)
         {
             dbEntry.PageTitle = pageBinding.PageTitle;
             dbEntry.MenuCategoryId = pageBinding.MenuCategoryId;
             dbEntry.ListMenuId = pageBinding.ListMenuId;
             dbEntry.AddMenuId = pageBinding.AddMenuId;
         }
     }
     context.SaveChanges();
 }