public void AddDailyReport(int sprintId, int employeeId, int reportId) { if (!repository.CheckIdExistence(sprintId)) { throw new NonexistentSprint(); } if (!employeeService.CheckExistence(employeeId)) { throw new NonexistentEmployee(); } if (!reportService.CheckExistence(reportId)) { throw new NonexistentReport(); } if (!reportService.CheckForCompleteness(reportId)) { throw new ReportTimeIsOver(); } SprintReportDTO sprintReportDto = ConvertDalToBbl(repository.GetById(sprintId)); if (DateTime.Compare(sprintReportDto.ClosingDate, MyDate.GetDate()) < 0) { throw new SprintTimeIsOver(); } List <int> subordiatesId = new List <int>(); employeeService.GetSubordinatesId(sprintReportDto.DirectorId, subordiatesId); if (employeeId == sprintReportDto.DirectorId || subordiatesId.Contains(employeeId)) { if (sprintReportDto.GetReports().Contains(reportId)) { throw new DailyReportAlreadyAdded(); } sprintReportDto.AddReport(reportId); repository.Update(ConvertBblToDal(sprintReportDto)); return; } throw new InsufficientRights(); }
public SprintReport ConvertBblToDal(SprintReportDTO entity) { return(new SprintReport(entity.Id, entity.DirectorId, entity.CreationDate, entity.ClosingDate, entity.Text, entity.GetReports())); }