示例#1
0
        public async Task <MeetingDTO> CreateMeeting(MeetingDTO _MeetingDTO)
        {
            var CourseID  = _courseService.GetCourseIdByName(_MeetingDTO.CourseName);
            var TeacherID = _teacherService.GetTeacherIdByName(_MeetingDTO.TeacherFullName);

            if (!_teacherService.CheckLinkToCourse(CourseID, TeacherID))
            {
                throw new InvalidExpressionException("Teacher not linked to Course");
            }

            var meeting = new Meeting
            {
                MeetingLink   = _MeetingDTO.MeetingLink,
                StartDateTime = _MeetingDTO.StartDateTime,
                TeacherID     = TeacherID,
                Duration      = _MeetingDTO.Duration,
                Description   = _MeetingDTO.Description,
                CourseID      = CourseID,
                Homework      = _MeetingDTO.Homework,
            };

            _context.Meetings.Add(meeting);
            await _context.SaveChangesAsync();

            return(new MeetingDTO());
        }
        public async Task <FeedbackLearnerTeacherDTO> AddTeacherFeedback(FeedbackLearnerTeacherDTO _FeedbackLearnerTeacherDTO)
        {
            var feedbackLeanerTeacher = new FeedbackLearnerTeacher()
            {
                TeacherID         = _teacherService.GetTeacherIdByName(_FeedbackLearnerTeacherDTO.TeacherName),
                LearnerID         = _FeedbackLearnerTeacherDTO.LeanerID,
                FeedbackDetails   = _FeedbackLearnerTeacherDTO.FeedbackDetails,
                RatingFromLearner = _FeedbackLearnerTeacherDTO.RatingFromLearner,
            };
            var updateTeacher = await _teacherService.UpdateRating(feedbackLeanerTeacher.TeacherID, feedbackLeanerTeacher.RatingFromLearner);

            _context.FeedbackLearnerTeachers.Add(feedbackLeanerTeacher);
            await _context.SaveChangesAsync();

            return(new FeedbackLearnerTeacherDTO());
        }