Example #1
0
        public ActionResult EditReview(ReviewSubmitionViewModel model, string Submit)
        {
            _logger.Log("Nomination-EditReview-POST");
            var currentNomination = _nominationService.GetNomination(model.NominationId);
            var customDate        = _customDateService.GetCustomDate(currentNomination.AwardId);
            var alreadyReviewed   = _encourageDatabaseContext.Query <Review>().FirstOrDefault(r => r.ReviewerId == model.ReviewerId && r.NominationId == model.NominationId);
            var previousComments  = _encourageDatabaseContext.Query <ReviewerComment>().Where(r => r.ReviewerId == model.ReviewerId && r.NominationId == model.NominationId).ToList();

            foreach (var previousComment in previousComments)
            {
                _encourageDatabaseContext.Delete <ReviewerComment>(previousComment);
            }
            if (alreadyReviewed != null)
            {
                _encourageDatabaseContext.Delete <Review>(alreadyReviewed);
                _encourageDatabaseContext.SaveChanges();
            }

            var review = new Review();

            review.NominationId = model.NominationId;
            review.ReviewerId   = model.ReviewerId;
            review.ReviewDate   = customDate;


            if (!string.IsNullOrEmpty(Submit) && Submit == "Submit")
            {
                review.IsSubmited = true;
            }

            if (!string.IsNullOrEmpty(Submit) && Submit == "Save Draft")
            {
                review.IsSubmited = false;
            }

            if (!string.IsNullOrEmpty(Submit) && Submit != "Discard Review")
            {
                _nominationService.AddReviewForCurrentNomination(review);

                foreach (var item in model.Comments)
                {
                    var revrComment = new ReviewerComment()
                    {
                        NominationId = model.NominationId,
                        ReviewerId   = model.ReviewerId,
                        CriteriaId   = item.CriteriaId,
                        Comment      = item.Comment != null ? item.Comment : "",
                        Credit       = Convert.ToInt32(item.Credit),
                        ReviewId     = review.Id
                    };
                    _nominationService.AddReviewerCommentsForCurrentNomination(revrComment);
                }
                if (review.IsSubmited == true)
                {
                    _nominationService.UpdateFinalScore(model.NominationId);
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
        public void DeletePrevoiusManagerComments(int nominationId)
        {
            var managerCommentsToDelete = _encourageDatabaseContext.Query <ManagerComment>().Where(comment => comment.NominationId == nominationId).ToList();

            foreach (var managerComments in managerCommentsToDelete)
            {
                _encourageDatabaseContext.Delete <ManagerComment>(managerComments);
            }
        }
Example #3
0
        public void UnShortlistNomination(int nominationId)
        {
            var shortlistedNomination = _encourageDatabaseContext.Query <Shortlist>().SingleOrDefault(model => model.NominationId == nominationId);

            if (shortlistedNomination != null)
            {
                _encourageDatabaseContext.Delete <Shortlist>(shortlistedNomination);
            }
        }
Example #4
0
        public void DeletePrevoiusReviewerComments(int reviewerId, int nominationID)
        {
            var previousComments = _encourageDatabaseContext.Query <ReviewerComment>().Where(r => r.ReviewerId == reviewerId && r.NominationId == nominationID).ToList();

            foreach (var previousComment in previousComments)
            {
                _encourageDatabaseContext.Delete(previousComment);
            }
        }
Example #5
0
        public bool ReSetCustomDate(int awardId)
        {
            var customDate = _encourageDbcontext.Query <CustomDate>().FirstOrDefault(x => x.AwardId == awardId);

            if (customDate != null)
            {
                _encourageDbcontext.Delete(customDate);
                return(true);
            }
            return(false);
        }