Ejemplo n.º 1
0
 /// <summary>
 /// Get Question Vm
 /// </summary>
 /// <returns>Instance of QuestionVm</returns>
 public QuestionVm GetQuestionVm()
 {
     return(new QuestionVm
     {
         Categories = SkillDataAccesor.GetSkillsWithQuestionCount(),
         Questions = new List <Question>()
     });
 }
Ejemplo n.º 2
0
 public List <Skill> AddSkill(Skill category)
 {
     if (SkillDataAccesor.AddSkill(category))
     {
         return(SkillDataAccesor.GetAllSkillsForApp());
     }
     return(null);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Add New feedback for user
        /// </summary>
        /// <param name="feedback">instance of feedback object</param>
        /// <returns>success flag wether feedback was added or not</returns>
        public bool AddFeedback(Feedback feedback)
        {
            feedback.Project = feedback.Project ?? new Project();

            if (feedback.FeedbackType.FeedbackTypeId == (int)FeedbackType.Skill)
            {
                if (!string.IsNullOrEmpty(feedback.Title))
                {
                    Skill newSkill = new Skill
                    {
                        Name    = feedback.Title,
                        AddedBy = feedback.AddedBy.UserId,
                        AddedOn = DateTime.Now
                    };

                    newSkill.SkillId = SkillDataAccesor.AddNewSkillForId(newSkill);

                    //Since new skill update the skill data
                    feedback.Skill.SkillId = newSkill.SkillId;
                    feedback.Skill.Name    = feedback.Title;
                }

                feedback.Title = feedback.Skill.Name;
                feedback.Skill = new Skill
                {
                    SkillId = feedback.Skill.SkillId
                };
            }
            else
            {
                feedback.Skill = new Skill();
            }

            // no way comment can have feedback rating
            if (feedback.FeedbackType.FeedbackTypeId == (int)FeedbackType.Comment || feedback.FeedbackType.FeedbackTypeId == (int)FeedbackType.Course)
            {
                feedback.Rating = 0;
            }

            feedback.Title = string.IsNullOrEmpty(feedback.Title) ? feedback.FeedbackType.Description : feedback.Title;

            int feedbackId = FeedbackDataAccesor.AddFeedback(feedback);

            if (!(feedbackId > 0))
            {
                return(false);
            }

            feedback.FeedbackId = feedbackId;

            return(new NotificationBl().AddFeedbackNotification(feedback));
        }
Ejemplo n.º 4
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
            });
        }
Ejemplo n.º 5
0
 public UserProfileVm GetUserProfileVm(int userId)
 {
     return(new UserProfileVm
     {
         User = UserDataAccesor.GetUserById(userId),
         Skills = SkillDataAccesor.GetSkillsByUserId(userId),
         AllSkills = SkillDataAccesor.GetAllSkillsForApp(),
         Sessions = SessionDataAccesor.GetSessionsByUserId(userId),
         Projects = ProjectDataAccesor.GetProjectsByUserId(userId),
         Feedbacks = FeedbackDataAccesor.GetUserFeedback(userId, 5),
         RecentCrFeedback = FeedbackDataAccesor.GetUserFeedback(userId, 100, 4),
         FeedbackTypes = new List <FeedbackType>
         {
             new FeedbackType
             {
                 FeedbackTypeId = 1, Description = "Comment"
             },
             new FeedbackType
             {
                 FeedbackTypeId = 2, Description = "Skill"
             },
             new FeedbackType
             {
                 FeedbackTypeId = 3, Description = "Assignment"
             },
             new FeedbackType
             {
                 FeedbackTypeId = 4, Description = "Code Review"
             },
             new FeedbackType
             {
                 FeedbackTypeId = 5, Description = "Weekly Feedback"
             }
         }
     });
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Insert New Skills
 /// </summary>
 /// <param name="skill">Instance of Skill Entity</param>
 /// <returns>Success flag for Insertion</returns>
 public bool AddSkill(Skill skill)
 {
     return(SkillDataAccesor.AddSkill(skill));
 }
Ejemplo n.º 7
0
 /// <summary>
 ///  Get List of all skills
 /// </summary>
 /// <returns>List of Skills if exists otherwise null</returns>
 public List <Skill> GetAllSkills()
 {
     return(SkillDataAccesor.GetAllSkillsForApp());
 }