Пример #1
0
        public ActionResult ViewNominationForShortlist(int nominationId)
        {
            _logger.Log("Review-ViewNominationForShortlist-GET");
            ViewBag.NominationLockStatus = _nominationService.GetNominationLockStatus();
            var     reviews             = _reviewService.GetReviewsForNomination(nominationId).ToList();
            var     nomination          = _nominationService.GetNomination(nominationId);
            var     allReviewerComments = new List <List <ReviewerCommentViewModel> >();
            decimal totalCreditPoints   = 0;

            var isHistoricalNomination = IsHistoricalNomination(nomination);

            foreach (var r in reviews)
            {
                foreach (var rc in r.ReviewerComments)
                {
                    var managerCommnet = nomination.ManagerComments.FirstOrDefault(mc => mc.CriteriaId == rc.CriteriaId);
                    totalCreditPoints += (Convert.ToInt32(rc.Credit) * (managerCommnet != null ? managerCommnet.Weightage : 0) / 100m);
                }
            }

            foreach (var review in reviews)
            {
                var allreviewerComment = _encourageDatabaseContext.Query <ReviewerComment>().Where(model => model.ReviewId == review.Id);
                var reviewer           = _encourageDatabaseContext.Query <Reviewer>().FirstOrDefault(model => model.Id == review.ReviewerId);
                var reviewerObj        = _commonDbContext.Query <User>().FirstOrDefault(u => u.ID == reviewer.UserId);

                var reviewerCommentList = new List <ReviewerCommentViewModel>();
                foreach (var reviewerComment in allreviewerComment)
                {
                    var singleReviewerComent = new ReviewerCommentViewModel()
                    {
                        CriteriaId   = reviewerComment.CriteriaId,
                        Comment      = reviewerComment.Comment,
                        Credit       = Convert.ToInt32(reviewerComment.Credit),
                        ReviewerName = reviewerObj != null ? reviewerObj.DisplayName : string.Empty
                    };
                    reviewerCommentList.Add(singleReviewerComent);
                }
                allReviewerComments.Add(reviewerCommentList);
            }

            var awardOfCurrentNomination = _awardService.GetAwardFromNominationId(nominationId);
            var isLocked = GetLockStatusOfAward(awardOfCurrentNomination.Id);

            var isShortlisted     = false;
            var isWinner          = false;
            var checkResultStatus = _resultService.IsShortlistedOrWinner(nomination.Id);

            if (checkResultStatus == 1)
            {
                isWinner = true;
            }
            else if (checkResultStatus == 2)
            {
                isShortlisted = true;
            }

            var nominee = _commonDbContext.Query <User>().FirstOrDefault(u => u.ID == nomination.UserId);

            var loggedInAdminId  = _awardService.GetUserIdFromEmail(User.Identity.Name);
            var hrAdminsFeedback = _resultService.GetHrAdminsFeedbackForEmployee(loggedInAdminId, nomination.Id);

            var shortlistViewModel = new ViewShortlistDetailsViewModel()
            {
                NominationId        = nomination.Id,
                UserName            = nominee != null ? nominee.DisplayName : string.Empty,
                TotalCredits        = totalCreditPoints,
                Manager             = _nominationService.GetManagerNameOfCurrentNomination(nominationId),
                ProjectOrDepartment = nomination.ProjectID != null?
                                      _nominationService.GetProjectNameOfCurrentNomination(nomination.Id) :
                                          _nominationService.GetDeptNameOfCurrentNomination(nomination.Id),
                                          NominationComment      = nomination.Comment,
                                          IsShortlisted          = isShortlisted,
                                          IsWinner               = isWinner,
                                          ReviewerComments       = allReviewerComments,
                                          Criterias              = _nominationService.GetCriteriaForNomination(nomination.Id),
                                          ManagerComments        = nomination.ManagerComments.ToList(),
                                          IsLocked               = isLocked,
                                          HrAdminsfeedback       = hrAdminsFeedback,
                                          HrAdminName            = _resultService.GetLoggedInUserName(User.Identity.Name),
                                          IsHistoricalNomination = isHistoricalNomination
            };

            return(View(shortlistViewModel));
        }