Exemple #1
0
 public int Create(Report entity)
 {
     entity.Id           = reports.Keys.Count == 0 ? 1 : reports.Keys.Max() + 1;
     entity.CreationDate = MyDate.GetDate();
     reports.Add(entity.Id, entity);
     return(entity.Id);
 }
Exemple #2
0
        public void AddCompletedTask(int reportId, int taskId)
        {
            if (!taskService.CheckExistence(taskId))
            {
                throw new NonexistentTask();
            }
            TaskDTO taskDto = taskService.Get(taskId);

            if (taskDto.Status != Task.TaskStatus.Resolved)
            {
                throw new NonresolvedTask();
            }
            ReportDTO reportDto = ConvertDalToBbl(repository.GetById(reportId));

            if (MyDate.GetDate().Day != reportDto.CreationDate.Day ||
                MyDate.GetDate().Month != reportDto.CreationDate.Month ||
                MyDate.GetDate().Year != reportDto.CreationDate.Year)
            {
                throw new TaskTimeIsOver();
            }
            if (reportDto.GetCompletedTasks().Contains(taskId))
            {
                throw new TaskAlreadyCompleted();
            }
            reportDto.AddCompletedTask(taskId);
            repository.Update(ConvertBblToDal(reportDto));
        }
Exemple #3
0
 public int Create(TaskChange entity)
 {
     entity.Id         = changes.Keys.Count == 0 ? 1 : changes.Keys.Max() + 1;
     entity.ChangeDate = MyDate.GetDate();
     changes.Add(entity.Id, entity);
     return(entity.Id);
 }
Exemple #4
0
        public bool CheckForCompleteness(int reportId)
        {
            ReportDTO reportDto = ConvertDalToBbl(repository.GetById(reportId));

            return(reportDto.CreationDate.Day != MyDate.GetDate().Day ||
                   reportDto.CreationDate.Month != MyDate.GetDate().Month ||
                   reportDto.CreationDate.Year != MyDate.GetDate().Year);
        }
Exemple #5
0
 public int Create(Task entity)
 {
     entity.Id               = tasks.Keys.Count == 0 ? 1 : tasks.Keys.Max() + 1;
     entity.CreationDate     = MyDate.GetDate();
     entity.LastModifiedDate = entity.CreationDate;
     entity.Status           = Task.TaskStatus.Open;
     tasks.Add(entity.Id, entity);
     return(entity.Id);
 }
Exemple #6
0
        public void AddComment(int taskId, int employeeId, string text)
        {
            if (!repository.CheckIdExistence(taskId))
            {
                throw new NonexistentTask();
            }
            TaskDTO taskDto = ConvertDalToBbl(repository.GetById(taskId));

            taskDto.AddComment(text);
            taskDto.LastModifiedDate = MyDate.GetDate();
            repository.Update(ConvertBblToDal(taskDto));
            changeRepository.Create(ConvertBblToDal(new TaskChangeDTO(taskId, employeeId, "New comment added")));
        }
Exemple #7
0
        public void UpdateText(int reportId, string text)
        {
            ReportDTO reportDto = ConvertDalToBbl(repository.GetById(reportId));

            if (MyDate.GetDate().Day != reportDto.CreationDate.Day ||
                MyDate.GetDate().Month != reportDto.CreationDate.Month ||
                MyDate.GetDate().Year != reportDto.CreationDate.Year)
            {
                throw new ReportTimeIsOver();
            }
            reportDto.UpdateText(text);
            repository.Update(ConvertBblToDal(reportDto));
        }
Exemple #8
0
        static void Main(string[] args)
        {
            EmployeeRepository employeeRepository = new EmployeeRepository();
            EmployeeService    employeeService    = new EmployeeService(employeeRepository);
            EmployeeController employeeController = new EmployeeController(employeeService);



            TaskRepository       taskRepository       = new TaskRepository();
            TaskChangeRepository taskChangeRepository = new TaskChangeRepository();
            TaskService          taskService          = new TaskService(taskRepository, taskChangeRepository, employeeService);
            TaskController       taskController       = new TaskController(taskService);

            int firstId = employeeController.AddEmployee("1st");
            int secId   = employeeController.AddEmployee("2nd", firstId);
            int thirdId = employeeController.AddEmployee("3rd", firstId);

            employeeController.ChangeDirector(thirdId, secId);
            //employeeController.ChangeDirector(secId, thirdId);

            int firstTaskId  = taskController.AddTask("first task", "first task description");
            int secondTaskId = taskController.AddTask("second task", "second task description");

            taskController.AssignEmployee(firstTaskId, firstId);
            taskController.AssignEmployee(secondTaskId, secId);
            taskController.AddComment(firstTaskId, firstId, "comment text");
            taskController.CompleteTask(firstTaskId, firstId);
            List <ViewTaskModel> list1 = taskController.GetSubordinatesTasks(firstId);
            List <ViewTaskModel> list2 = taskController.GetTasksByEmployee(firstId);
            List <ViewTaskModel> list3 = taskController.GetTasksModifiedByEmployee(firstId);

            ReportRepository reportRepository = new ReportRepository();
            ReportService    reportService    = new ReportService(reportRepository, taskService);
            ReportController reportController = new ReportController(reportService);
            int firstReportId = reportController.CreateReport(firstId, "first report text");

            reportController.UpdateText(firstReportId, "first report fixed text");
            //MyDate.date = MyDate.date.AddDays(1);
            reportController.UpdateText(firstReportId, "first report twice fixed text");
            List <ViewReportModel> list = reportController.GetReportsByEmployee(firstId);

            SprintReportRepository sprintReportRepository = new SprintReportRepository();
            SprintReportService    sprintReportService    = new SprintReportService(sprintReportRepository, employeeService, reportService);
            SprintReportController sprintReportController = new SprintReportController(sprintReportService);
            int firstSprintId = sprintReportController.CreateSprintReport(firstId, MyDate.GetDate().AddDays(2));

            MyDate.date = MyDate.date.AddDays(1);
            sprintReportController.AddDailyReport(firstSprintId, firstId, firstReportId);
        }
Exemple #9
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();
        }