// Get One basic table, used for housing maintenace request // DEFAULT // RETURNS A LIST OF MAINTENANCE REQUESTS ALL // change public IEnumerable <MaintenanceRequestWithTenantMapper> GetMaintenanceRequestsAll() { var content = db.MaintenanceRequests.ToList(); if (content.Count() == 0) { return(null); } else { List <MaintenanceRequestWithTenantMapper> requests = new List <MaintenanceRequestWithTenantMapper>(); TenantsHelper tenant = new TenantsHelper(); foreach (var item in content) { MaintenanceRequestWithTenantMapper request = new MaintenanceRequestWithTenantMapper { Active = item.active ?? default(bool), MaintenanceRequestId = item.maintenanceRequestId, Message = item.message, TenantId = item.tenantId ?? default(int), Tenant = tenant.GetTenantForRequests(item.tenantId ?? 0) }; requests.Add(request); } return(requests); } }
//Get all requests with supplies // Default // RETURNS ONE SUPPLY REQUEST BY TENANT ID WITH: Mapping with Supplies // change all public IEnumerable <SupplyRequestWithTenant> GetSupplyRequestWithSuppliesAll() { var content = db.SupplyRequests.ToList(); if (content.Count() == 0) { return(null); } else { List <SupplyRequestWithTenant> requests = new List <SupplyRequestWithTenant>(); RequestSuppliesMapsHelper map = new RequestSuppliesMapsHelper(); TenantsHelper tenant = new TenantsHelper(); foreach (var item in content) { SupplyRequestWithTenant request = new SupplyRequestWithTenant { SupplyRequestId = item.supplyRequestId, TenantId = item.tenantId ?? default(int), Active = item.active ?? default(bool), RequestSuppliesMaps = map.GetRequestSuppliesMapsWithSupplyByRequest(item.supplyRequestId), Tenant = tenant.GetTenantForRequests(item.tenantId ?? 0) }; requests.Add(request); } return(requests); } }