Exemplo n.º 1
0
        /// <summary>
        /// Retrieve a classroom by id
        /// TODO use converter for ClassRoomDto
        /// </summary>
        /// <param name="classRoomId"></param>
        /// <returns></returns>
        public ClassRoomDto GetClassRoomById(int classRoomId)
        {
            logger.Trace("Service received request to return classroom by Id {classRoomId}", classRoomId);
            var classRoom = db.ClassRoomsRepository.GetByID(classRoomId);

            if (classRoom == null)
            {
                return(null);
            }

            return(ClassRoomConverter.ClassRoomToClassRoomDto(classRoom));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Delete a classroom
        /// </summary>
        /// <param name="classRoomId"></param>
        /// <returns></returns>
        public ClassRoomDto DeleteClassRoom(int classRoomId)
        {
            logger.Trace("Service received a request to delete classroom {classRoomId}", classRoomId);

            ClassRoom classRoom = db.ClassRoomsRepository.GetByID(classRoomId);

            if (classRoom == null)
            {
                return(null);
            }

            db.ClassRoomsRepository.Delete(classRoom);
            db.Save();

            return(ClassRoomConverter.ClassRoomToClassRoomDto(classRoom));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update classroom data
        /// </summary>
        /// <param name="classRoomId"></param>
        /// <param name="classRoom"></param>
        /// <returns></returns>
        public ClassRoomDto UpdateClassRoom(int classRoomId, ClassRoomDto classRoom)
        {
            logger.Trace("Service received a request to update classroom Id {classRoomId} with data {classRoomData}", classRoomId, classRoom);
            ClassRoom updatedClassRoom = db.ClassRoomsRepository.GetByID(classRoomId);

            if (updatedClassRoom == null)
            {
                return(null);
            }

            updatedClassRoom.ClassGrade = classRoom.SchoolGrade;
            updatedClassRoom.Name       = classRoom.Name;

            db.ClassRoomsRepository.Update(updatedClassRoom);
            db.Save();

            return(ClassRoomConverter.ClassRoomToClassRoomDto(updatedClassRoom));
        }