public static CompanyType GetCompanyType(CompanyTypeEnum type) { using (var context = new BackofficeUnitOfWork()) { string companyType = type.ToString(); return(context.CompanyType .Fetch() .Where(i => i.Token == companyType && i.Active) .FirstOrDefault()); } }
public static List <ListItem> GetCompanyServices(CompanyTypeEnum type) { using (var context = new BackofficeUnitOfWork()) { string companyType = type.ToString(); return(context.CompanyService .Fetch() .Include(i => i.CompanyType) .Where(i => i.CompanyType.Token == companyType && i.Active) .Select(i => new ListItem() { Key = i.ID, Value = i.Description }) .ToList()); } }
public List <PageEntity> GetPagesForRole(int roleId, CompanyTypeEnum companyType) { var accessData = from ma in DataContext.MarsUserRoleMenuAccesses where ma.MarsUserRoleId == roleId select ma; var baseAccess = from ma in DataContext.MarsUserRoleMenuAccesses where ma.MarsUserRole.BaseAccess && ma.MarsUserRole.CompanyType.CompanyTypeName == companyType.ToString() select ma; var loggedOnEmployee = ApplicationAuthentication.GetEmployeeId(); var userHasSysAdmin = DataContext.MarsUserUserRoles.FirstOrDefault( d => d.MarsUser.EmployeeId == loggedOnEmployee && d.MarsUserRole.AdminAccess); var roleData = from rm in DataContext.RibbonMenus join ad in accessData on rm.UrlId equals ad.UrlId into joinedData from jd in joinedData.DefaultIfEmpty() join ba in baseAccess on rm.UrlId equals ba.UrlId into joinedBaseData from jbd in joinedBaseData.DefaultIfEmpty() where rm.ParentId != null && rm.Enabled.HasValue && rm.Enabled.Value select new PageEntity { UrlId = rm.UrlId, PageName = rm.Title, Url = rm.Url, Assigned = jd != null, IsBranch = rm.ParentId == 1, BaseHasAccess = jbd != null, ParentId = rm.ParentId.HasValue ? rm.ParentId.Value : 0, Enabled = userHasSysAdmin != null, MenuId = rm.MenuId.HasValue ? rm.MenuId.Value : 0 }; var localRoleData = roleData.ToList(); var returned = GetTreeStructurePages(localRoleData); return(returned); }
//public const int CorporateId = 1; public static int GetIdForCompanyType(CompanyTypeEnum typeRequested, MarsDBDataContext dataContext = null) { if (dataContext == null) { using (var dc = new MarsDBDataContext()) { var companyTypeId = dc.CompanyTypes.FirstOrDefault(d => d.CompanyTypeName == typeRequested.ToString()); if (companyTypeId == null) { throw new InvalidOperationException("Invalid CompanyType, change Enum CompanyTypeId to match Database table"); } return(companyTypeId.CompanyTypeId); } } else { var companyTypeId = dataContext.CompanyTypes.FirstOrDefault(d => d.CompanyTypeName == typeRequested.ToString()); if (companyTypeId == null) { throw new InvalidOperationException("Invalid CompanyType, change Enum CompanyTypeId to match Database table"); } return(companyTypeId.CompanyTypeId); } }
public int GetCompanyIdForType(CompanyTypeEnum companyType) { int returned = 0; if (companyType == CompanyTypeEnum.Corporate) { var companyTypeId = DataContext.CompanyTypes.FirstOrDefault(d => d.CompanyTypeName == companyType.ToString()); if (companyTypeId == null) { throw new InvalidOperationException("Corporate CompanyType not found"); } returned = companyTypeId.CompanyTypeId; } if (companyType == CompanyTypeEnum.Licensee) { var companyTypeId = DataContext.CompanyTypes.FirstOrDefault(d => d.CompanyTypeName == companyType.ToString()); if (companyTypeId == null) { throw new InvalidOperationException("Liscensee CompanyType not found"); } returned = companyTypeId.CompanyTypeId; } return(returned); }