/// <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)); }
public bool SubmitCodeReviewFeedback(CodeReview codeReview) { CodeReviewMetaData codeReviewMetaData = UnitOfWork.CodeReviewRepository.GetCodeReviewWithAllData(codeReview.Id); CodeReview codeReviewDetailsFromCore = CodeReviewConverter.ConvertFromCore(codeReviewMetaData); Feedback feedback = new Feedback { AddedBy = new User { UserId = codeReview.AddedBy.UserId }, AddedFor = new User { UserId = codeReview.AddedFor.UserId }, FeedbackType = new Common.Entity.FeedbackType { FeedbackTypeId = (int)FeedbackType.CodeReview }, FeedbackText = UtilityFunctions.GenerateCodeReviewPreview(codeReviewDetailsFromCore, true), Skill = new Skill(), Project = new Project(), Title = codeReviewDetailsFromCore.Title, Rating = codeReview.Rating }; int feedbackId = FeedbackDataAccesor.AddFeedback(feedback); if (!(feedbackId > 0)) { return(false); } codeReviewMetaData.FeedbackId = feedback.FeedbackId = feedbackId; codeReviewMetaData.SystemRating = CalculateCodeReviewRating(codeReviewDetailsFromCore); UnitOfWork.Commit(); return(new NotificationBl().AddFeedbackNotification(feedback)); // return AddFeedback(feedback); }
public bool AddFeedback(Feedback feedback) { feedback.Project = feedback.Project ?? new Project(); //feedback.Skill = (feedback.Skill == null) ? new Skill() : feedback.Skill; feedback.Title = string.IsNullOrEmpty(feedback.Title) ? feedback.FeedbackType.Description : feedback.Title; if (feedback.FeedbackType.FeedbackTypeId == 2) { feedback.Title = feedback.Skill.Name; feedback.Skill = new Skill { SkillId = feedback.Skill.SkillId }; } else { feedback.Skill = new Skill(); } return(FeedbackDataAccesor.AddFeedback(feedback)); }
public bool UpdateAssignmentProgress(Assignment data, User currentUser, out int feedbackId) { feedbackId = 0; bool isAssignmentFeedback = false; if (data != null && data.TraineeId > 0) { // return false if trainee will not allowed to approve the completion of assignment or trainer cannot mark assignment as completed or trainer cannot approve/reassign assignment without feedback. if ((currentUser.IsTrainee && data.TraineeId != currentUser.UserId && data.IsApproved) || (!currentUser.IsTrainee && data.IsCompleted && !data.IsApproved) || (!currentUser.IsTrainee && data.Feedback.Count < 1)) { return(false); } if (!currentUser.IsTrainee) { var feedback = data.Feedback.FirstOrDefault(x => x.FeedbackId == 0); feedback.AddedBy = currentUser; feedback.AddedFor = new UserBl().GetUserByUserId(data.TraineeId); feedback.AddedOn = DateTime.Now; if (feedback.FeedbackType.FeedbackTypeId == (int)Common.Enumeration.FeedbackType.Comment) { feedback.Rating = 0; } feedback.Skill = new Skill(); feedback.Project = new Project(); feedbackId = FeedbackDataAccesor.AddFeedback(feedback); if (feedbackId == 0 || !FeedbackDataAccesor.AddFeedbackAssignmentMapping(feedbackId, data.Id)) { return(false); } feedback.FeedbackId = feedbackId; new NotificationBl().AddFeedbackNotification(feedback); data.ApprovedBy = currentUser.UserId; if (feedback.FeedbackType.FeedbackTypeId == (int)Common.Enumeration.FeedbackType.Assignment) { isAssignmentFeedback = true; } } var status = LearningPathDataAccessor.UpdateAssignmentProgress(data); if (!status || !isAssignmentFeedback || currentUser.IsTrainee) { return(status); } CourseTrackerDetails courseDetails = LearningPathDataAccessor.GetCourseDetailBasedOnParameters(data.TraineeId, data.Id); if (courseDetails != null && courseDetails.PercentageCompleted.CompareTo(100) == 0) { return(LearningPathDataAccessor.CompleteCourseForTrainee(courseDetails.Id, data.TraineeId) && new FeedbackBl().GenerateCourseFeedback(courseDetails.Id, data.TraineeId)); } return(true); } return(false); }