예제 #1
0
        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();
        }
예제 #2
0
 public SprintReport ConvertBblToDal(SprintReportDTO entity)
 {
     return(new SprintReport(entity.Id, entity.DirectorId, entity.CreationDate, entity.ClosingDate, entity.Text, entity.GetReports()));
 }
예제 #3
0
 public int Add(SprintReportDTO entity)
 {
     return(repository.Create(ConvertBblToDal(entity)));
 }