public static PersonalRiskAssessmentDto CreateFrom(MultiHazardRiskAssessment riskAssessment) { if (riskAssessment == null) return null; DateTime? createdOn = null; if (riskAssessment.CreatedOn != null) { createdOn = riskAssessment.CreatedOn.Value; } return new PersonalRiskAssessmentDto { Id = riskAssessment.Id, CompanyId = riskAssessment.CompanyId, AssessmentDate = riskAssessment.AssessmentDate, CreatedOn = createdOn, CreatedBy = new AuditedUserDtoMapper().Map(riskAssessment.CreatedBy), RiskAssessor = riskAssessment.RiskAssessor != null ? new RiskAssessorDtoMapper().MapWithEmployeeAndSite(riskAssessment.RiskAssessor) : null, Location = riskAssessment.Location, Reference = riskAssessment.Reference, RiskAssessmentSite = (riskAssessment.RiskAssessmentSite != null) ? new SiteStructureElementDto() { Id = riskAssessment.RiskAssessmentSite.Id, Name = riskAssessment.RiskAssessmentSite.Name } : null, TaskProcessDescription = riskAssessment.TaskProcessDescription, Title = riskAssessment.Title, Employees = riskAssessment.Employees != null ? new RiskAssessmentEmployeeDtoMapper().MapWithEmployee(riskAssessment.Employees) : null, NonEmployees = riskAssessment.NonEmployees != null ? new RiskAssessmentNonEmployeeDtoMapper().MapWithNonEmployee(riskAssessment.NonEmployees) : null, Deleted = riskAssessment.Deleted, Status = riskAssessment.Status, NextReviewDate = riskAssessment.Reviews.Any() ? riskAssessment.Reviews.OrderByDescending(x => x.Id).First().CompletionDueDate : null }; }
public static GeneralRiskAssessmentDto CreateFrom(MultiHazardRiskAssessment riskAssessment) { if (riskAssessment == null) return null; DateTime? createdOn = null; if (riskAssessment.CreatedOn != null) createdOn = riskAssessment.CreatedOn.Value; return new GeneralRiskAssessmentDto { Id = riskAssessment.Id, CompanyId = riskAssessment.CompanyId, AssessmentDate = riskAssessment.AssessmentDate, CreatedOn = createdOn, CreatedBy = new AuditedUserDtoMapper().Map(riskAssessment.CreatedBy), Location = riskAssessment.Location, Reference = riskAssessment.Reference, RiskAssessmentSite = (riskAssessment.RiskAssessmentSite != null) ? new SiteStructureElementDto() {Id = riskAssessment.RiskAssessmentSite.Id, Name = riskAssessment.RiskAssessmentSite.Name} : null, TaskProcessDescription = riskAssessment.TaskProcessDescription, Title = riskAssessment.Title, RiskAssessor = riskAssessment.RiskAssessor != null ? new RiskAssessorDtoMapper().Map(riskAssessment.RiskAssessor) : null, Employees = riskAssessment.Employees != null ? new RiskAssessmentEmployeeDtoMapper().MapWithEmployee(riskAssessment.Employees) : null, NonEmployees = riskAssessment.NonEmployees != null ? new RiskAssessmentNonEmployeeDtoMapper().MapWithNonEmployee(riskAssessment.NonEmployees) : null, Deleted = riskAssessment.Deleted, Status = riskAssessment.Status, PeopleAtRisk = new List<PeopleAtRiskDto>(), NextReviewDate = riskAssessment.Reviews.Any() ? riskAssessment.Reviews.OrderByDescending(x => x.Id).First().CompletionDueDate : null, Reviews = riskAssessment.Reviews.Select(entity => new RiskAssessmentReviewDto() { Comments = entity.Comments, CompletedBy = entity.CompletedBy != null ? new EmployeeDtoMapper().MapWithNationalityAndContactDetailsAndEmergencyContactDetails(entity.CompletedBy) : null, CompletedDate = entity.CompletedDate, CompletionDueDate = entity.CompletionDueDate, Id = entity.Id, IsReviewOutstanding = entity.IsReviewOutstanding, ReviewAssignedTo = entity.ReviewAssignedTo != null ? new EmployeeDtoMapper().MapWithUser(entity.ReviewAssignedTo) : null, RiskAssessmentReviewTask = entity.RiskAssessmentReviewTask != null ? new TaskDtoMapper().MapWithAssignedTo(entity.RiskAssessmentReviewTask) as RiskAssessmentReviewTaskDto : null }).ToList() }; }