public async Task <DashboardPropertyViewModel> GetDashboardPropertiesViewModelAsync(int propertyId = 0) { var inspections = (await GetInspectionsByPropertyIdAsync(propertyId)).ToList(); var incidents = (await GetIncidentsByPropertyIdAsync(propertyId)).ToList(); DashboardPropertyViewModel viewModel = new DashboardPropertyViewModel(); foreach (var inspection in inspections) { if (inspection.sl_propertyID != null) { if (inspection.sl_propertyID.Id > 0) { inspection.sl_propertyID.propertyImgUrl = await GetPropertyPhotoAsync(inspection.sl_propertyID.Id); if (propertyId > 0 && viewModel.PropertyDetail == null) { viewModel.PropertyDetail = inspection.sl_propertyID; } } } } foreach (var incident in incidents) { if (incident.sl_inspectionIDId != null) { incident.inspection = inspections.Where(i => i.Id == incident.sl_inspectionIDId.Value).FirstOrDefault(); } if (incident.sl_propertyID.Id > 0) { incident.sl_propertyID.propertyImgUrl = await GetPropertyPhotoAsync(incident.sl_propertyID.Id); } } viewModel.Inspections = inspections; viewModel.Incidents = incidents; return(viewModel); }
public async Task<DashboardPropertyViewModel> GetDashboardPropertiesViewModel(int propertyId = 0) { var inspections = (await GetInspectionsByPropertyId(propertyId)).ToList(); var incidents = (await GetIncidentsByPropertyId(propertyId)).ToList(); DashboardPropertyViewModel viewModel = new DashboardPropertyViewModel(); foreach (var inspection in inspections) { if (inspection.sl_propertyID != null) { if (inspection.sl_propertyID.Id > 0) { inspection.sl_propertyID.propertyImgUrl = await GetPropertyPhoto(inspection.sl_propertyID.Id); if (propertyId > 0 && viewModel.PropertyDetail == null) { viewModel.PropertyDetail = inspection.sl_propertyID; } } } } foreach (var incident in incidents) { if (incident.sl_inspectionIDId != null) { incident.inspection = inspections.Where(i => i.Id == incident.sl_inspectionIDId.Value).FirstOrDefault(); } if (incident.sl_propertyID.Id > 0) { incident.sl_propertyID.propertyImgUrl = await GetPropertyPhoto(incident.sl_propertyID.Id); } } viewModel.Inspections = inspections; viewModel.Incidents = incidents; return viewModel; }