public void SelectWinner(int nominationId, string winningComment, string hrAdminsFeedback, int adminId)
        {
            var shortlistedNomination = _encourageDatabaseContext.Query <Shortlist>().SingleOrDefault(model => model.NominationId == nominationId);
            var currentNomination     = shortlistedNomination != null?_encourageDatabaseContext.Query <Nomination>().FirstOrDefault(x => x.Id == shortlistedNomination.NominationId) : _encourageDatabaseContext
                                            .Query <Nomination>().FirstOrDefault(x => x.Id == nominationId);

            if (currentNomination != null)
            {
                var customDate = _customDateService.GetCustomDate(currentNomination.AwardId);

                if (shortlistedNomination != null)
                {
                    shortlistedNomination.IsWinner         = true;
                    shortlistedNomination.WinningDate      = customDate.Date;
                    shortlistedNomination.WinningComment   = winningComment;
                    shortlistedNomination.HrAdminsFeedback = hrAdminsFeedback;
                    shortlistedNomination.AdminId          = adminId;
                    _encourageDatabaseContext.Update <Shortlist>(shortlistedNomination);
                }
                else
                {
                    var winner = new Shortlist()
                    {
                        IsWinner     = true,
                        NominationId = nominationId,
                        //WinningDate = DateTime.Now.Date,
                        WinningDate      = customDate.Date,
                        WinningComment   = winningComment,
                        HrAdminsFeedback = hrAdminsFeedback,
                        AdminId          = adminId
                    };
                    _encourageDatabaseContext.Add <Shortlist>(winner);
                }
            }
        }
        public ActionResult SaveFinalScore(ConsolidatedNominationsViewModel consolidatedNominationsViewModel)
        {
            try
            {
                foreach (var nomination in consolidatedNominationsViewModel.Nominations)
                {
                    foreach (var finalComment in nomination.ManagerComments)
                    {
                        var commentDb = _encourageDatabaseContext.Query <ManagerComment>().FirstOrDefault(mc => mc.NominationId == finalComment.NominationId && mc.CriteriaId == finalComment.CriteriaId);
                        if (commentDb != null)
                        {
                            commentDb.AdminComment = finalComment.AdminComment;
                            commentDb.FinalScore   = finalComment.FinalScore;
                            _encourageDatabaseContext.Update(commentDb);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _logger.Log("Review-SaveFinalScore-POST-" + e.Message);
                throw;
            }


            return(Json(true));
        }
Exemple #3
0
        public bool SetCustomDate(int awardId, int month, int year, bool isApplicable)
        {
            var customDatesForAward = _encourageDbcontext.Query <CustomDate>().FirstOrDefault(x => x.AwardId == awardId);

            if (customDatesForAward != null)
            {
                if (month > 0)
                {
                    customDatesForAward.Month        = month;
                    customDatesForAward.Year         = year;
                    customDatesForAward.IsApplicable = isApplicable;
                    _encourageDbcontext.Update(customDatesForAward);
                    return(true);
                }
                else if (year > 0)
                {
                    customDatesForAward.Year         = year;
                    customDatesForAward.IsApplicable = isApplicable;
                    _encourageDbcontext.Update(customDatesForAward);
                    return(true);
                }
            }

            if (month > 0)
            {
                _encourageDbcontext.Add(new CustomDate {
                    AwardId = awardId, Month = month, Year = year, IsApplicable = isApplicable
                });
                return(true);
            }
            else if (year > 0)
            {
                _encourageDbcontext.Add(new CustomDate {
                    AwardId = awardId, Month = DateTime.Today.Month, Year = year, IsApplicable = isApplicable
                });
                return(true);
            }
            return(false);
        }
        public string UpdateEmailTemplate(int templateId, string updatedTemplate)
        {
            var toBeUpdatedTemplate = _encourageDatabaseContext.Query <EmailTemplate>().FirstOrDefault(t => t.Id == templateId);

            if (toBeUpdatedTemplate != null)
            {
                toBeUpdatedTemplate.Template = updatedTemplate;
                var returnedValue = _encourageDatabaseContext.Update(toBeUpdatedTemplate);
                if (returnedValue == 0)
                {
                    return("Error");
                }
            }
            return("Success");
        }
 public void UpdateReview(Review model)
 {
     _encourageDatabaseContext.Update(model);
 }
 public void UpdateNomination(Nomination model)
 {
     _encourageDatabaseContext.Update <Nomination>(model);
 }