public ActionResult Edit(Permission permission)
 {
     if (ModelState.IsValid)
     {
         accountRepository.SavePermission(permission);
         TempData["message"] = MessageHelper.BuildMessage(EnumSevereLevel.Success, string.Format("{0} has been created!", permission.PermissionName));
         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.PermissionCategories = accountRepository.PermissionCategories.ToList();
         return View(permission);
     }
 }
 public SelectPermissionEditorViewModel(Permission permission)
 {
     this.PermissionId = permission.PermissionId;
     this.PermissionName = permission.PermissionName;
 }
 public void SavePermission(Permission permission)
 {
     if (permission.PermissionId == 0)
     {
         context.Permissions.Add(permission);
     }
     else
     {
         Permission dbEntry = context.Permissions.Find(permission.PermissionId);
         if (dbEntry != null)
         {
             dbEntry.PermissionName = permission.PermissionName;
             dbEntry.PermissionCategoryId = permission.PermissionCategoryId;
             dbEntry.Sequence = permission.Sequence;
         }
     }
     context.SaveChanges();
 }