public ActionResult AssignPermissions() { var RolesList = _UserRolesService.GetRolesList(); var Roles = (from p in RolesList orderby p.Name select new RolesViewModel { RoleId = p.Id, RoleName = p.Name, }); return(View("RolesList", Roles)); }
public IEnumerable <SubModuleViewModel> GetSubModuleFromModuleForUsers(int id, string appuserid, List <string> RoleIds, int SiteId, int DivisionId) { //Testing Block var Roles = _userRolesService.GetRolesList().ToList(); var RoleId = string.Join(",", from p in Roles where RoleIds.Contains(p.Name) select p.Id.ToString()); //End var temp2 = (from p in _MenuRepository.Instance join t in _RolesMenuRepository.Instance on p.MenuId equals t.MenuId where (p.IsVisible.HasValue ? p.IsVisible == true : 1 == 1) && p.ModuleId == id && t.SiteId == SiteId && t.DivisionId == DivisionId && RoleId.Contains(t.RoleId) group p by new { p.SubModuleId, p.SubModule.SubModuleName } into res join t in _SubModuleRepository.Instance on res.Key.SubModuleId equals t.SubModuleId into table from tab in table.DefaultIfEmpty() select new SubModuleViewModel { ModuleId = id, SubModuleIconName = tab.IconName, SubModuleId = res.Key.SubModuleId, SubModuleName = res.Key.SubModuleName, Srl = res.Max(m => m.Srl), MenuViewModel = (from temp in res group temp by temp.MenuId into g orderby g.Max(m => m.Srl) select new MenuViewModel { MenuId = g.Key, MenuName = g.FirstOrDefault().MenuName, ModuleId = g.FirstOrDefault().ModuleId, SubModuleId = g.FirstOrDefault().SubModuleId, ControllerActionId = g.FirstOrDefault().ControllerActionId, Description = g.FirstOrDefault().Description, IconName = g.FirstOrDefault().IconName, Srl = g.FirstOrDefault().Srl, URL = g.FirstOrDefault().URL, BookMarked = ((from tek in _UserBookMarkRepository.Instance where tek.ApplicationUserName == appuserid && tek.MenuId == g.FirstOrDefault().MenuId select tek).Any() ), } ).ToList() }).ToList(); double x = 0; var SubModuleList = temp2.OrderBy(m => m.SubModuleId).ThenBy(sx => double.TryParse(sx.Srl, out x) ? x : 0); var tempSubModList = from p in SubModuleList group p by p.SubModuleId into g select g.FirstOrDefault(); return(tempSubModList); }
public IEnumerable <MenuModouleViewModel> GetModuleListForUser(List <string> Role, int SiteId, int DivisionId) { List <MenuModouleViewModel> ModuleList = new List <MenuModouleViewModel>(); //Testing Block var Roles = _userRolesService.GetRolesList().ToList(); var RoleId = string.Join(",", from p in Roles where Role.Contains(p.Name) select p.Id.ToString()); //End var pt = (from p in _unitOfWork.Repository <RolesMenu>().Instance join t in _unitOfWork.Repository <Menu>().Instance on p.MenuId equals t.MenuId join t2 in _unitOfWork.Repository <MenuModule>().Instance on t.ModuleId equals t2.ModuleId where p.SiteId == SiteId && p.DivisionId == DivisionId && RoleId.Contains(p.RoleId) group t2 by t2.ModuleId into g select g.FirstOrDefault() ); if (pt != null) { ModuleList = (from p in pt select new MenuModouleViewModel { IconName = p.IconName, IsActive = p.IsActive, ModuleId = p.ModuleId, ModuleName = p.ModuleName, Srl = p.Srl, URL = p.URL, }).ToList(); } return(ModuleList); }
public IEnumerable <RolesControllerActionViewModel> GetRolesControllerActionsForRoles(List <String> Roles) { var temp = _UserRolesService.GetRolesList().ToList(); var RoleIds = string.Join(",", from p in temp where Roles.Contains(p.Name) select p.Id.ToString()); var Temp = (from p in _RolesControllerActionRepository.Instance where RoleIds.Contains(p.RoleId) select new RolesControllerActionViewModel { ControllerActionId = p.ControllerActionId, ControllerActionName = p.ControllerAction.ActionName, ControllerName = p.ControllerAction.Controller.ControllerName, RoleId = p.RoleId, RoleName = p.Role.Name, RolesControllerActionId = p.RolesControllerActionId }); return(Temp); }
public ActionResult SiteSelection() { //var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db)); string UserId = User.Identity.GetUserId(); string UserName = User.Identity.GetUserName(); //using (StreamWriter writer = new StreamWriter(Server.MapPath("/release_notification_emails.txt"), true)) //{ // writer.WriteLine("Tracking STart"); // writer.WriteLine("User Id : " + UserId); // writer.WriteLine("User Name : " + UserName); //} var userInRoles = _userRolesService.GetUserRolesList(UserId); if (userInRoles.Count() == 0) { string URoles = (string)System.Web.HttpContext.Current.Session["LoginUserRole"]; if (userInRoles.Count() <= 0 && !(_userRolesService.TryInsertUserRole(UserId, UserName, URoles))) { AuthenticationManager.SignOut(); FormsAuthentication.SignOut(); Session.Abandon(); return(View("NoRoles")); } Session.Remove("LoginUserRole"); } SiteSelectionViewModel vm = new SiteSelectionViewModel(); AssignSession(); IEnumerable <string> UserRoles = (List <string>)System.Web.HttpContext.Current.Session["Roles"]; //Testing Block var temp = _userRolesService.GetRolesList().ToList(); var RoleIds = string.Join(",", from p in temp where UserRoles.Contains(p.Name) select p.Id.ToString()); //End if (UserRoles.Contains("Admin")) { var SiteList = _siteSelectionService.GetSiteList().ToList(); ViewBag.SiteList = SiteList; var DivList = _siteSelectionService.GetDivisionList().ToList(); ViewBag.DivisionList = DivList; if (SiteList.Count == 1 && DivList.Count == 1) { AssignSiteDivModuleSession(SiteList.FirstOrDefault().SiteId, DivList.FirstOrDefault().DivisionId); return(RedirectToAction("DefaultGodownSelection")); } } else { var SiteList = _siteSelectionService.GetSiteList(RoleIds).ToList(); ViewBag.SiteList = SiteList; var DivList = _siteSelectionService.GetDivisionList(RoleIds).ToList(); ViewBag.DivisionList = DivList; if (SiteList.Count == 0 || DivList.Count == 0) { return(RedirectToAction("AccessDenied", "Account")); } else if (SiteList.Count == 1 && DivList.Count == 1) { AssignSiteDivModuleSession(SiteList.FirstOrDefault().SiteId, DivList.FirstOrDefault().DivisionId); return(RedirectToAction("DefaultGodownSelection")); } } if (System.Web.HttpContext.Current.Session["DivisionId"] != null && System.Web.HttpContext.Current.Session["SiteId"] != null) { vm.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; vm.SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; } return(View(vm)); }