Esempio n. 1
0
        /// <summary>
        /// Save weekly feedback and corresponding survey response
        /// </summary>
        /// <param name="response">instance of response</param>
        /// <returns>success flag </returns>
        public bool SaveWeeklySurveyResponseForTrainee(SurveyResponse response)
        {
            // Weekly feedback must have team associated with it.
            if (!response.AddedBy.TeamId.HasValue)
            {
                return(false);
            }

            try
            {
                Survey   survey             = SurveyDataAccesor.GetWeeklySurveySetForTeam(response.AddedBy.TeamId.Value);
                Feedback lastWeeklyFeedback = FeedbackDataAccesor.GetUserFeedback(response.AddedFor.UserId, 1, (int)Common.Enumeration.FeedbackType.Weekly)
                                              .FirstOrDefault();

                response.CodeReviewForTheWeek = FeedbackDataAccesor.GetUserFeedback(response.AddedFor.UserId,
                                                                                    1000,
                                                                                    (int)Common.Enumeration.FeedbackType.CodeReview)
                                                .Where(x => x.AddedOn.Date >= response.Feedback.StartDate &&
                                                       (lastWeeklyFeedback == null || x.AddedOn >= lastWeeklyFeedback.AddedOn))
                                                .ToList();

                response.Feedback.FeedbackText = GenerateHtmlforFeedback(response, survey);
                response.Feedback.FeedbackId   = SurveyDataAccesor.SaveWeeklySurveyResponseForTrainee(response, survey);
                return(response.Feedback.FeedbackId > 0 && new NotificationBl().AddFeedbackNotification(response.Feedback));
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Bussiness method to Fecth weekly survey Questions for team
        /// </summary>
        ///  <param name="traineeId">trainee id</param>
        /// <param name="startDate">feedback start Date</param>
        /// <param name="endDate">feedback end date</param>
        /// <param name="teamId">team id</param>
        /// <returns>Instance of survey id</returns>
        public SurveyVm FetchWeeklySurveyQuestionForTeam(int traineeId, DateTime startDate, DateTime endDate, int teamId)
        {
            Feedback lastWeeklyFeedback = FeedbackDataAccesor.GetUserFeedback(traineeId, 1, (int)Common.Enumeration.FeedbackType.Weekly)
                                          .FirstOrDefault();

            return(new SurveyVm()
            {
                Survey = SurveyDataAccesor.GetWeeklySurveySetForTeam(teamId),
                IsCodeReviewedForTrainee = FeedbackDataAccesor.GetUserFeedback(traineeId,
                                                                               1000,
                                                                               (int)Common.Enumeration.FeedbackType.CodeReview).Any(x => x.AddedOn.Date >= startDate.Date &&
                                                                                                                                    (lastWeeklyFeedback == null || x.AddedOn >= lastWeeklyFeedback.AddedOn))
            });
        }
Esempio n. 3
0
        /// <summary>
        /// Fetch Weekly feedback preview generated by survey
        /// </summary>
        /// <param name="response">instance of response</param>
        /// <returns>generated Html</returns>
        public string FetchWeeklyFeedbackPreview(SurveyResponse response)
        {
            // Weekly feedback must have team associated with it.
            if (!response.AddedBy.TeamId.HasValue)
            {
                return(string.Empty);
            }

            Survey   survey             = SurveyDataAccesor.GetWeeklySurveySetForTeam(response.AddedBy.TeamId.Value);
            Feedback lastWeeklyFeedback = FeedbackDataAccesor.GetUserFeedback(response.AddedFor.UserId, 1, (int)Common.Enumeration.FeedbackType.Weekly)
                                          .FirstOrDefault();

            response.CodeReviewForTheWeek = FeedbackDataAccesor.GetUserFeedback(response.AddedFor.UserId,
                                                                                1000,
                                                                                (int)Common.Enumeration.FeedbackType.CodeReview)
                                            .Where(x => x.AddedOn.Date >= response.Feedback.StartDate &&
                                                   (lastWeeklyFeedback == null || x.AddedOn >= lastWeeklyFeedback.AddedOn))
                                            .ToList();
            return(GenerateHtmlforFeedback(response, survey));
        }