public DepartmentDTOCreated CreateDepartment(DepartmentDTOIn newDepartment)
        {
            logger.Info("Getting grades for creating department over grades service, create department, department service");
            Grade grade = gradesService.GetGradeId(newDepartment.GradeID);

            logger.Info($"Creating department {newDepartment.DepartmentName}");
            Department department = new Department()
            {
                DepartmentName = newDepartment.DepartmentName,
                Grades         = grade
            };

            logger.Info($"Adding department {department.DepartmentName} to db");
            db.DepartmentsRepository.Insert(department);
            db.Save();

            logger.Info("Converting department to DTO");
            DepartmentDTOCreated departmentDTO = new DepartmentDTOCreated()
            {
                DepartmentName = department.DepartmentName,
                Grade          = Utilities.ConverterDTO.SimpleDTOConverter <GradeDTO>(department.Grades)
            };

            return(departmentDTO);
        }
Example #2
0
        public IHttpActionResult PostClassRoom(DepartmentDTOIn classRoom)
        {
            DepartmentDTOCreated classCreated = departmentsService.CreateDepartment(classRoom);

            return(Created("", classCreated));
        }