Example #1
0
        public async Task <ProfileViewModel> GetProfileViewModel(ApplicationUser profileUser, ApplicationUser currentSessionUser)
        {
            var ratingService = new FeedbackService();

            var currentU = await _userService.GetUserWithStudentsCoursesList(currentSessionUser.Id);

            var teacher = await _userService.GetTeacherUser(profileUser.Id);

            var profileVM = new ProfileViewModel();

            profileVM.User     = teacher;
            profileVM.Subjects = await _userService.GetLeadingSubjectListByTeacherId(profileUser.Id);

            profileVM.CourseTittles = await _courseService.GetCoursesTitlesByTeacher(profileUser.Id);

            profileVM.isReadyForRate     = ratingService.CheckIfProfileRaterValid(await _userService.GetUserWithLessonsList(currentSessionUser.Id), profileUser);
            profileVM.isReadyForComment  = ratingService.CheckIfCommentatorValid(currentU, teacher);
            profileVM.IsReadyForCreate   = ratingService.CheckIfReadyForCreate(profileUser);
            profileVM.isShowCertificates = currentU.Certificats.Count > 0;
            return(profileVM);
        }