Exemplo n.º 1
0
        public IHttpActionResult DeleteClass(int id)
        {
            logger.Info($"accessing department service for deleting of department id {id}");
            DepartmentDTOOutSingle classDeleted = departmentsService.DeleteDepartment(id);

            return(Ok(classDeleted));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetDepartmentByID(int id)
        {
            logger.Info("Getting all departments");
            DepartmentDTOOutSingle departments = departmentsService.GetDepartmentByID(id);

            return(Ok(departments));
        }
Exemplo n.º 3
0
        public DepartmentDTOOutSingle DeleteDepartment(int id)
        {
            logger.Info("Getting department by id, preparing for delete, deletedepartment, department service");
            DepartmentDTOOutSingle departmentDTO = GetDepartmentByID(id);

            if (departmentDTO == null)
            {
                logger.Info($"Department with ID {id} not found, throwing department not found exception");
                throw new DepartmentNotFoundException($"No department with ID {id}");
            }
            logger.Info($"Accessing department repo for delete of department id {id}");
            db.DepartmentsRepository.Delete(id);
            logger.Info($"Saving to db, department with ID {id} delete");
            db.Save();

            logger.Info($"Department id {id} deleted, returning deprtmentDTO");
            return(departmentDTO);
        }
Exemplo n.º 4
0
        public DepartmentDTOOutSingle GetDepartmentByID(int id)
        {
            logger.Info("Accessing department repo, getdepartmentbyid, departments service");
            Department department = db.DepartmentsRepository.GetByID(id);

            if (department == null)
            {
                throw new DepartmentNotFound($"Departments with {id} doesent exists");
            }

            DepartmentDTOOutSingle departmentDTO = new DepartmentDTOOutSingle()
            {
                Department = new DepartmentDTOStudent()
                {
                    Id             = department.Id,
                    DepartmentName = department.DepartmentName
                },
                Grade    = ConverterDTO.SimpleDTOConverter <GradeDTO>(department.Grades),
                Subjects = department.Grades.Subjects.Select(x => ConverterDTO.SimpleDTOConverter <SubjectDTO>(x))
            };

            return(departmentDTO);
        }