public List <CaseAuthorizationHours> GetCaseHoursByCaseByProvider(int caseID, int providerID, DateTime?cutoffDate = null) { var context = new Models.CoreEntityModel(); IQueryable <Models.CaseAuthHour> q; if (cutoffDate == null) { q = (from auths in context.CaseAuthCodes join hours in context.CaseAuthHours on auths.ID equals hours.CaseAuthID where auths.CaseID == caseID && hours.CaseProviderID == providerID select hours) .Union( from hours in context.CaseAuthHours where hours.CaseID == caseID && hours.CaseProviderID == providerID select hours ); } else { q = (from auths in context.CaseAuthCodes join hours in context.CaseAuthHours on auths.ID equals hours.CaseAuthID where auths.CaseID == caseID && hours.CaseProviderID == providerID && hours.HoursDate >= cutoffDate.Value select hours) .Union( from hours in context.CaseAuthHours where hours.CaseID == caseID && hours.CaseProviderID == providerID && hours.HoursDate >= cutoffDate.Value select hours ); } var providerHours = q.ToList(); var list = Mappings.AuthorizationMappings.CaseAuthorizationHours(providerHours); var services = GetServices(); var providerService = new ProviderService(); foreach (var hours in list) { hours.Service = services.Where(x => x.ID == hours.Service.ID).FirstOrDefault(); var provider = providerService.GetProvider(hours.ProviderID); Domain.Cases.CaseProvider cp = new CaseProvider(); cp.FirstName = provider.FirstName; cp.LastName = provider.LastName; hours.Provider = cp; } return(list); }
public Provider GetProvider(int providerID) { var providerService = new ProviderService(); return(providerService.GetProvider(providerID)); }