public ActionResult Edit(int id, int pid = 0)
        {
            try
            {
                var role = usertypebll.GetAllUserTypeAssignments();
                //var AllRoles = usertypebll.GetAllUserTypes();
                var AllRoles = UserRolebll.GetAllRoles();
                var AllModules = modulebll.GetAllModules();

                List<int> roAss = new List<int>();
                List<int> ModId = new List<int>();
                List<int> FinalModId = new List<int>();
                RoleAssignmentModel _userRoles = new RoleAssignmentModel();
                int take = 10;
                int skip = take * pid;
                _userRoles.PageID = pid;
                _userRoles.Current = pid + 1;
                ViewBag.c = _userRoles.PageID;
                List<RoleAssignmentModel> _Roles = objdb.RoleAssignments.Where(x => x.UserTypeId == id).Select(x => new RoleAssignmentModel
                {
                    RoleAssgnId = x.Id,
                    UserTypeId = x.UserTypeId,
                    RoleName = x.Role.RoleName,
                    ModuleName = x.Module.ModuleName,
                    ModuleId = x.ModuleId,
                    IsAdd = x.IsAdd,
                    IsEdit = x.IsEdit,
                    IsDelete = x.IsDelete,
                    IsView = x.IsView,
                    IsEnable = x.IsEnable,
                    IsActive = x.IsActive
                }).ToList();

                // selecting ModuleId from RoleAssignment table based on RoleId
                roAss = (from mi in role where mi.UserTypeId == id select mi.ModuleId).ToList();
                // Select All ModuleId from Module...
                ModId = (from mo in AllModules select mo.ModuleId).ToList();

                // RoleAssignment not containing Module 
                foreach (int str in ModId)
                {
                    if (!roAss.Contains(str))
                        FinalModId.Add(str);
                }

                List<RoleAssignmentModel> _allMod = new List<RoleAssignmentModel>();
                _allMod = AllModules.Select(x => new RoleAssignmentModel
                {
                    ModuleId = x.ModuleId,
                    ModuleName = x.ModuleName,
                    IsAdd = false,
                    IsEdit = false,
                    IsDelete = false,
                    IsView = false,
                    IsEnable = false,
                    IsActive = false,
                }).ToList();

                // Adding Role module list to  new Module which are not in list
                foreach (var item in _allMod)
                {
                    if (FinalModId.Contains(item.ModuleId))
                    {
                        _Roles.Add(item);
                    }
                }
                List<RoleModal> _roleModel = AllRoles.Select(x => new RoleModal
                {
                    RoleId = x.RoleId,
                    RoleName = x.RoleName,

                }).ToList();

                _userRoles.UserTypeId = id;
                _userRoles.ModuleList = _Roles;
                _userRoles.RolesModel = _roleModel;
                Session["ModList"] = _Roles;
                return View(_userRoles);
            }
            catch (Exception e)
            {
                //ViewBag.msg = "Refersh Page ";
                //return RedirectToAction("Index");
                throw e;
            }
        }