예제 #1
0
 public List <Session> GetAllSessionForAttendee(int userId, DateTime startDate, DateTime endDate)
 {
     return(SessionConverter.ConvertListFromCore(UnitOfWork.SessionRepository.GetAllSessionForAttendee(userId)
                                                 .Where(x => x.SessionDate.HasValue &&
                                                        x.SessionDate >= startDate &&
                                                        x.SessionDate <= endDate)
                                                 .ToList()));
 }
예제 #2
0
        /// <summary>
        /// Get view model for user profile page
        /// </summary>
        /// <param name="userId">user id</param>
        /// <param name="loggedInUser"></param>
        /// <returns>instance of User vm</returns>
        public UserProfileVm GetUserProfileVm(int userId, User loggedInUser)
        {
            User requestedUser = userId == loggedInUser.UserId ? loggedInUser : UserDataAccesor.GetUserById(userId);

            CodeReview codeReview = loggedInUser.IsTrainer || loggedInUser.IsManager
                                        ? CodeReviewConverter.ConvertFromCore(UnitOfWork.CodeReviewRepository.GetSavedCodeReviewForTrainee(userId, loggedInUser.UserId))
                                        : null;
            var commonTags = UnitOfWork.CodeReviewRepository
                             .GetCommonlyUsedTags(userId, 5)
                             .Select(skill => new CodeReviewTag
            {
                CodeReviewTagId = 0,
                Skill           = new Skill
                {
                    Name    = skill.Name,
                    SkillId = skill.SkillId
                }
            }).ToList();

            if (codeReview != null)
            {
                codeReview.CodeReviewPreviewHtml = UtilityFunctions.GenerateCodeReviewPreview(codeReview, true);
                codeReview.SystemRating          = new FeedbackBl().CalculateCodeReviewRating(codeReview);
            }

            return(new UserProfileVm
            {
                User = userId == loggedInUser.UserId ? null : requestedUser,
                Skills = requestedUser.IsTrainee ? SkillDataAccesor.GetSkillsByUserId(userId) : null,
                TraineeSynopsis = requestedUser.IsTrainee ? FeedbackDataAccesor.GetTraineeFeedbackSynopsis(requestedUser.UserId) : null,
                Sessions = requestedUser.IsTrainee ? SessionConverter.ConvertListFromCore(UnitOfWork.SessionRepository.GetAllSessionForAttendee(userId)) : null,
                Projects = null,
                Feedbacks = requestedUser.IsTrainee ? FeedbackDataAccesor.GetUserFeedback(userId, 5) : FeedbackDataAccesor.GetFeedbackAddedByUser(userId),
                TrainorSynopsis = requestedUser.IsTrainer || requestedUser.IsManager ? FeedbackDataAccesor.GetTrainorFeedbackSynopsis(requestedUser.UserId) : null,
                AllAssignedCourses = requestedUser.IsTrainee ? LearningPathDataAccessor.GetAllCoursesForTrainee(requestedUser.UserId).OrderByDescending(x => x.PercentageCompleted).ToList() : new List <CourseTrackerDetails>(),
                SavedCodeReview = codeReview,
                CommonTags = commonTags
                             //  SavedCodeReviewData = logedInUser.IsTrainer && (codeReview != null && codeReview.Id > 0) ? UtilityFunctions.GenerateCodeReviewPreview(codeReview, true) : string.Empty
            });
        }
예제 #3
0
        private PagedResult <Session> GetPagedFilteredSessions(string wildcard, int statusId, int searchSessionId
                                                               , int teamId, int pageNumber, int pageSize)
        {
            var session = UnitOfWork.SessionRepository.GetPagedFilteredSessions(wildcard, (Common.Enumeration.SessionType)statusId, searchSessionId,
                                                                                teamId, pageNumber, pageSize);

            if (session == null)
            {
                return(new PagedResult <Session>());
            }

            return(new PagedResult <Session>
            {
                CurrentPage = session.CurrentPage,
                PageCount = session.PageCount,
                PageSize = session.PageSize,
                RowCount = session.RowCount,
                Results = session.Results == null
                           ? new List <Session>()
                           : SessionConverter.ConvertListFromCore(session.Results.ToList())
            });
        }