public ActionResult Updatepermission(Permissionviewmodel vm) { List <string> result = new List <string>(); PermissionMaster _master = new PermissionMaster(); List <ModulePermission> p = new List <ModulePermission>(); Guid CompanyId = new Guid(); if (Request.Cookies["CompanyId"] != null) { CompanyId = new Guid(Commonhelper.GetCookie("CompanyId")); } Permissionviewmodel searchmodel = new Permissionviewmodel(); if (vm.PermissionMaster != null) { _master.Id = vm.Id; _master.CompanyId = CompanyId.ToString(); _master.UserId = vm.UserId; _master.ModifiedBy = User.Identity.GetUserId(); _master.Datemodified = DateTime.Now; _master.Workstation = Commonhelper.GetStation(); } if (vm.Menumaster.Count() > 0) { foreach (var item in vm.Menumaster) { foreach (var child in item._SubMenumaster) { if (child.IsAdd == true || child.IsEdit == true || child.Isview == true || child.Isdelete == true) { ModulePermission mp = new ModulePermission(); mp.Id = Guid.NewGuid().ToString(); mp.MenuId = item.MenuId; mp.SubMenuId = child.SubMenumasterId; mp.IsAdd = child.IsAdd; mp.IsEdit = child.IsEdit; mp.Isview = child.Isview; mp.Isdelete = child.Isdelete; mp.DisplayOrder = Commonhelper.GetSubmenuOrder(mp.SubMenuId); mp.Displayclass = child.Displayclass; mp.DisplayName = child.DisplayName; _master._ModulePermission.Add(mp); } } } try { Commonhelper.UpdatePermission(_master); return(RedirectToAction("RegisteredAccounts")); ////return Content("<script language='javascript' type='text/javascript'>alert('permission update successfully!');</script>"); } catch (Exception ex) { } } //List<Permission> permissions = new List<Permission>(); //List<ModulePermission> _MPermission = new List<ModulePermission>(); //try //{ // if(pm!=null) // { // pm.Datemodified = DateTime.Now; // pm.ModifiedBy = User.Identity.GetUserId(); // if (pm._Permission.Count() > 0) // { // foreach(var item in pm._Permission) // { // Permission p = new Permission(); // p.DisplayOrder = item.DisplayOrder; // p.Id = Guid.NewGuid(); // p.Isactive = item.Isactive; // p.MenuId = item.MenuId; // p.PermissionMasterId = pm.Id; // p.Displayclass = item.Displayclass; // p.DisplayName = item.DisplayName; // permissions.Add(p); // } // pm._Permission.Clear(); // pm._Permission = permissions; // foreach(var child in pm._ModulePermission) // { // ModulePermission mp = new ModulePermission(); // mp.Id = Guid.NewGuid(); // mp.PermissionMasterId = pm.Id; // mp.MenuId = child.MenuId; // mp.SubMenuId = child.SubMenuId; // mp.IsAdd = child.IsAdd; // mp.IsEdit = child.IsEdit; // mp.Isview = child.Isview; // mp.Isdelete = child.Isdelete; // mp.DisplayOrder = child.DisplayOrder; // mp.Displayclass = child.Displayclass; // mp.DisplayName = child.DisplayName; // _MPermission.Add(mp); // } // pm._ModulePermission.Clear(); // pm._ModulePermission.AddRange(_MPermission); // try // { // Commonhelper.SavePermission(_master); // /// Commonhelper.UpdatePermission(pm); // } // catch(Exception ex) // { // result.Add("Internal server Issue try again."); // } // } // } // return Content("<script language='javascript' type='text/javascript'>alert('permission update successfully!');</script>"); // //result.Add("permission update successfully."); // //ModelState.Clear(); // //return Json(new { url = Url.Action("UserLevelPermission") }); //} //catch(Exception ex) //{ // result.Add("Internal server Issue try again."); //} return(Json(result)); }