//Method added by Shashank on Nov-3 2014 /// <summary> /// Gets the corporate facility tab list. /// </summary> /// <param name="corporateid">The corporateid.</param> /// <param name="facilityid">The facilityid.</param> /// <param name="roleId"></param> /// <returns></returns> public IEnumerable <TabsCustomModel> GetCorporateFacilityTabList(int corporateid, int facilityid, int?roleId) { var list = new List <TabsCustomModel>(); using (var tabsRepository = UnitOfWork.TabsRepository) { using (var mBal = new ModuleAccessBal()) { using (var rBal = new RoleTabsBal()) { var tabs = tabsRepository.Where(t => !t.TabName.ToLower().Equals("setup")) .OrderBy(x => x.TabOrder) .ToList(); var moduleAccess = mBal.GetModulesAccessList(corporateid, facilityid).ToList(); if (roleId != null) { var roleTabs = rBal.GetRoleTabsByRoleId(roleId).ToList(); roleTabs = roleTabs.Where( t => (moduleAccess.Any(z => z.TabID == t.TabID))).ToList(); var customlist = tabs.Where( t => (roleTabs.Any(z => z.TabID == t.TabId))).ToList(); if (!customlist.Any()) { customlist = tabs.Where( t => (moduleAccess.Any(z => z.TabID == t.TabId))).ToList(); } list.AddRange(customlist.Select(item => new TabsCustomModel { CurrentTab = item, ParentTabName = GetTabNameById(item.ParentTabId), HasChilds = HasChildren(item.TabId) })); } else { var newlist = tabs.Where( t => (moduleAccess.Any(z => z.TabID == t.TabId))).ToList(); list.AddRange(newlist.Select(item => new TabsCustomModel { CurrentTab = item, ParentTabName = GetTabNameById(item.ParentTabId), HasChilds = HasChildren(item.TabId) })); } } } } return(list); }
//Method added by Shashank on Nov-3 2014 /// <summary> /// Gets the parent corporate facility tab list. /// </summary> /// <param name="corporateid">The corporateid.</param> /// <param name="facilityid">The facilityid.</param> /// <returns></returns> public List <TabsCustomModel> GetParentCorporateFacilityTabList(int corporateid, int facilityid) { var list = new List <TabsCustomModel>(); using (var tabsRepository = UnitOfWork.TabsRepository) { using (var moduleaccessBal = new ModuleAccessBal()) { var tabs = tabsRepository.GetAll().OrderBy(t => t.TabName).ToList(); var moduleAccess = moduleaccessBal.GetModulesAccessList(corporateid, facilityid).ToList(); var newlist = corporateid == 0 ? tabs : tabs.Where(t => moduleAccess.Any(z => z.TabID == t.TabId) && !t.TabName.Equals("Setup")).ToList(); list.AddRange(newlist.Select(item => new TabsCustomModel { CurrentTab = item, ParentTabName = GetTabNameById(item.ParentTabId), HasChilds = HasChildren(item.TabId) })); } } return(list); }