public string PDRCurrentStatusName(PDReview pdr) { CurrentPDRStatuses midYearStatus = CurrentPDRStatus(pdr, Current_YearStatus.MidYear); CurrentPDRStatuses fullYearStatus = CurrentPDRStatus(pdr, Current_YearStatus.FullYear); if (fullYearStatus == CurrentPDRStatuses.Completed) { return(String.Format("You are viewing {0}'s full year PDR for year {0}, Full year PDR completed.", pdr.ReviewPeriod.Year, pdr.ReviewerEmailId)); } else if (fullYearStatus == CurrentPDRStatuses.Started) { return(String.Format("You are viewing {1}'s full year PDR for year {0}, Full year PDR is in Progress.", pdr.ReviewPeriod.Year, pdr.ReviewerEmailId)); } else if (midYearStatus == CurrentPDRStatuses.Completed) { return(String.Format("You are viewing {1}'s mid year PDR for year {0}, Mid year PDR completed.", pdr.ReviewPeriod.Year, pdr.ReviewerEmailId)); } else if (midYearStatus == CurrentPDRStatuses.Started) { return(String.Format("You are viewing {1}'s mid year PDR for year {0}, Mid year PDR is in Progress.", pdr.ReviewPeriod.Year, pdr.ReviewerEmailId)); } else { return(String.Format("You are viewing {1}'s full year PDR for year {0}, Mid year PDR {2} & Full year PDR {3}. .", pdr.ReviewPeriod.Year, pdr.ReviewerEmailId, CurrentPDRStatus(pdr, Current_YearStatus.MidYear), CurrentPDRStatus(pdr, Current_YearStatus.FullYear))); } }
public Rating CalculateSuccessFactorOverAllRating(PDReview pdr) { if (MidOrFull(pdr) == Current_YearStatus.MidYear) { //makle sure all the mid year is saved var getAvgMidyearRating = pdr.SuccessFactors.Average(x => GetSingleRatings(x.MidYearRating).ScoreFrom); var midRating = GetAllRatings(pdr.UserTypeId, 3).FirstOrDefault(x => x.ScoreTo >= getAvgMidyearRating && x.ScoreFrom <= getAvgMidyearRating); if (midRating != null) { return(midRating); } } else if (MidOrFull(pdr) == Current_YearStatus.FullYear) { var getAvgMidyearRating = pdr.SuccessFactors.Average(x => GetSingleRatings(x.MidYearRating).ScoreFrom); var getAvgFullYearRating = pdr.SuccessFactors.Average(x => GetSingleRatings(x.FullYearRating).ScoreFrom); var full = (getAvgMidyearRating + getAvgFullYearRating) / 2; var fullRating = GetAllRatings(pdr.UserTypeId, 3).FirstOrDefault(x => x.ScoreTo >= full && x.ScoreFrom <= full); if (fullRating != null) { return(fullRating); } } return(GetSingleRatings(1)); }
public IEnumerable <ValidationResult> CanSaveOverallAnnualRatings(PDReview pdr) { //Mid year is in Progress if (pdr.MidYearStatus == 2) { if (pdr.Objectives.Any(x => x.MidYearRating == 0)) { yield return(new ValidationResult("SelectedOverallRatingId", "Make sure mid year rating is complete/save before saving overall objective.")); } if (pdr.SuccessFactors.Any(x => x.MidYearRating == 0)) { yield return(new ValidationResult("SelectedOverallRatingId", "Please complete ratings first.")); } } //Full year is in Progress if (pdr.FullYearStatus == 2) { if (pdr.Objectives.Any(x => x.FullYearRating == 0)) { yield return(new ValidationResult("SelectedOverallRatingId", "Make sure full year rating is complete/save before saving overall objective.")); } if (pdr.SuccessFactors.Any(x => x.FullYearRating == 0)) { yield return(new ValidationResult("SelectedOverallRatingId", "Please complete ratings first.")); } } }
public void CompleteFullYearPDR(PDReview pdr) { if (pdr != null) { Rating objR = CalculateObjectiveOverAllRating(pdr); Rating sfR = CalculateSuccessFactorOverAllRating(pdr); pdr.ObjectiveOverallRatingId = objR.ID; pdr.SuccessFactorOverallRatingId = sfR.ID; pdr.FullYearObjectiveOverallScore = objR.ScoreFrom; pdr.FullYearSuccessFactorOverallScore = sfR.ScoreFrom; Rating ovR = CalculateAnnualOverAllRating(pdr, objR.ScoreFrom, sfR.ScoreFrom); pdr.OverallRatingId = ovR.ID; pdr.FullYearOverallScore = ovR.ScoreFrom; pdr.IsMidYear = false; pdr.IsFullYear = false; pdr.FullYearStatus = 3; UpdatePDR(pdr); } }
public void ResponseForUnLock(ApplicationUser loggedInUser, PDReview pdr, string response) { if (pdr.IsLocked && (pdr.LockedBy.Equals(loggedInUser.UserName))) { pdr.AccessResponse = response; UpdatePDR(pdr); } }
//public void CreatePDR(ApplicationUser user, UserType userType, DateTime reviewPeriod) //{ // //Create PDR // PDReview pdr = new PDReview(); // { // pdr.UserTypeId = userType.ID; // pdr.ApplicationUserId = user.Id; // pdr.ReviewPeriod = reviewPeriod; // pdr.MidYearStatus = 1; // pdr.FullYearStatus = 1; // pdr.LockedAt = DateTime.Now; // pdr.LockedBy = user.Email; // } // _PDRReviewRepository.Add(pdr); // SavePDR(); // if (pdr != null) // { // // Create Objective // var objectivesTypes = _ObjectiveTyperepository.GetAll().Where(x => x.UserTypeId == userType.ID); // foreach (var objectiveType in objectivesTypes) // { // var objective = new Objective(); // objective.ObjectiveTypeId = objectiveType.ID; // objective.PDReviewId = pdr.ID; // _ObjectiveRepository.Add(objective); // } // var successFactorTypes = _SuccessFactorTypeRepository.GetAll().Where(x => x.UserTypeId == userType.ID); // foreach (var successFactorType in successFactorTypes) // { // var successFactor = new SuccessFactor(); // successFactor.SuccessFactorTypeId = successFactorType.ID; // successFactor.PDReviewId = pdr.ID; // _SuccessFactorRepository.Add(successFactor); // } // SavePDR(); // } //} public void CreatePDR(ApplicationUser user, ApplicationUser reviewUser, DateTime?reviewPeriod = null) { var rPeriod = reviewPeriod.HasValue ? reviewPeriod.Value : GenerateNextAvailableReviewPeriod(reviewUser); if (!IsThisPDRAllReadyExist(reviewUser, rPeriod)) { //Create PDR PDReview pdr = new PDReview(); { pdr.UserTypeId = reviewUser.UserTypeId; pdr.ApplicationUserId = user.Id; pdr.ReviewPeriod = rPeriod; pdr.MidYearStatus = 1; pdr.FullYearStatus = 1; pdr.ReviewerEmailId = reviewUser.UserName; pdr.ReviewerUserId = reviewUser.Id; } _PDRReviewRepository.Add(pdr); SavePDR(); if (pdr != null) { // Create Objective var objectivesTypes = _ObjectiveTyperepository.GetAll().Where(x => x.UserTypeId == reviewUser.UserTypeId); foreach (var objectiveType in objectivesTypes) { var objective = new Objective(); objective.ObjectiveTypeId = objectiveType.ID; objective.PDReviewId = pdr.ID; _ObjectiveRepository.Add(objective); } var successFactorTypes = _SuccessFactorTypeRepository.GetAll().Where(x => x.UserTypeId == reviewUser.UserTypeId); foreach (var successFactorType in successFactorTypes) { var successFactor = new SuccessFactor(); successFactor.SuccessFactorTypeId = successFactorType.ID; successFactor.PDReviewId = pdr.ID; _SuccessFactorRepository.Add(successFactor); } var develpmentCategories = _IDevelopmentCategoryRepository.GetAll().Where(x => x.UserTypeId == reviewUser.UserTypeId); foreach (var develpmentCategory in develpmentCategories) { var pdPlan = new PersonalDevelopmentPlan(); pdPlan.PDReviewId = pdr.ID; _IPersonalDevelopmentPlanRepository.Add(pdPlan); } SavePDR(); } } }
public bool IsAnyAccessRequest(ApplicationUser loggedInUser, PDReview pdr) { if (pdr.LockedBy.Equals(loggedInUser.UserName)) { return(!string.IsNullOrEmpty(pdr.AccessRequest)); } return(false); }
public bool IsAnyAccessResponse(ApplicationUser loggedInUser, PDReview pdr) { if (pdr.LockedBy.ToLower() != loggedInUser.UserName.ToLower()) { return(!string.IsNullOrEmpty(pdr.AccessResponse)); } return(false); }
public void RequestForUnLock(ApplicationUser loggedInUser, PDReview pdr) { if (pdr.IsLocked) { pdr.AccessRequest = "Please can I access. "; pdr.AcessRequestedUserId = loggedInUser.Id; UpdatePDR(pdr); } }
public WhoAmI WhoAamI(ApplicationUser appUser, PDReview pdr) { if (appUser.Id == pdr.ReviewerUserId) { return(WhoAmI.Colleague); } else if (appUser.UserName.ToLower().Equals(pdr.LineManagerEmailId.ToLower())) { return(WhoAmI.LineManager); } return(WhoAmI.Manager); }
public Current_YearStatus MidOrFull(PDReview pdr) { if (pdr.IsMidYear) { return(Current_YearStatus.MidYear); } else if (pdr.IsFullYear) { return(Current_YearStatus.FullYear); } return(Current_YearStatus.MidYear); }
public void ForceUnLockPDR(ApplicationUser loggedInUser, PDReview pdr) { if (loggedInUser.UserName.Equals(pdr.LockedBy)) { pdr.IsLocked = false; pdr.LockedAt = null; pdr.LockEndTime = null; pdr.LockedBy = string.Empty; pdr.AccessRequest = string.Empty; pdr.AcessRequestedUserId = string.Empty; UpdatePDR(pdr); } }
public bool DisableWholePDRDetailsView(ApplicationUser loggedInUser, PDReview selectedPDR) { if (!IsLockedByCurrentUser(loggedInUser, selectedPDR)) { return(true); } if (selectedPDR.FullYearStatus == 2 || selectedPDR.MidYearStatus == 2) { return(false); } return(true); }
public CurrentPDRStatuses CurrentPDRStatus(PDReview pdr, Current_YearStatus midOrFull) { switch (midOrFull) { case Current_YearStatus.MidYear: return((CurrentPDRStatuses)GetPDRStatus(pdr.MidYearStatus).ID); case Current_YearStatus.FullYear: return((CurrentPDRStatuses)GetPDRStatus(pdr.FullYearStatus).ID); default: return((CurrentPDRStatuses)GetPDRStatus(pdr.MidYearStatus).ID); } }
public static Tuple <string, string> ToCurrentFullYearPDRStatuses(this PDReview MyPDR) { if (MyPDR.FullYearStatus == 3) { return(new Tuple <string, string>("Full year is completed", "label-success")); } else if (MyPDR.FullYearStatus == 2) { return(new Tuple <string, string>("Full year is In Progress", "label-warning")); } else { return(new Tuple <string, string>("Full year is not started", "label-danger")); } }
public IEnumerable <ValidationResult> CanCompleteFullYearPDR(PDReview pdr) { if (pdr.FullYearStatus == 2) { if (pdr.Objectives.Any(x => x.FullYearRating == 0)) { yield return(new ValidationResult("PDRListErrors", "At the moment cannot complete, make sure you complete all the mid year ratings.")); } if (pdr.SuccessFactors.Any(x => x.FullYearRating == 0)) { yield return(new ValidationResult("PDRListErrors", "At the moment cannot complete, make sure you complete all the success factor mid year ratings.")); } } }
public Rating CalculateAnnualOverAllRating(PDReview pdr, int objfrom, int successfactorfrom) { //makle sure all the mid year is saved //var objOverallRating = GetSingleRatings(pdr.ObjectiveOverallRatingId.Value).ScoreFrom; //var sfOverallRating = GetSingleRatings(pdr.SuccessFactorOverallRatingId.Value).ScoreFrom; var getAvgAnnualRating = (objfrom + successfactorfrom) / 2; var annualRating = GetAllRatings(pdr.UserTypeId, 3).FirstOrDefault(x => x.ScoreTo >= getAvgAnnualRating && x.ScoreFrom <= getAvgAnnualRating); if (annualRating != null) { return(annualRating); } return(GetSingleRatings(1)); }
public void DenyUnLockRequest(ApplicationUser loggedInUser, PDReview pdr) { int lockTimeOut; if (!int.TryParse(ConfigurationManager.AppSettings["LockTimeOut"], out lockTimeOut)) { lockTimeOut = 20; } pdr.IsLocked = true; pdr.LockedAt = DateTime.UtcNow; pdr.LockEndTime = DateTime.UtcNow.AddMinutes(lockTimeOut); pdr.LockedBy = loggedInUser.UserName; pdr.AccessResponse = pdr.AcessRequestedUserId; pdr.AccessRequest = string.Empty; pdr.AcessRequestedUserId = string.Empty; UpdatePDR(pdr); }
public IEnumerable <ValidationResult> CanSaveOverallSuccessFactorRatings(PDReview pdr) { //Mid year is in Progress if (pdr.MidYearStatus == 2) { if (pdr.SuccessFactors.Any(x => x.MidYearRating == 0)) { yield return(new ValidationResult("SelectedSuccessFactorOverallRatingId", "Please complete ratings first.")); } } //Full year is in Progress if (pdr.FullYearStatus == 2) { if (pdr.SuccessFactors.Any(x => x.FullYearRating == 0)) { yield return(new ValidationResult("SelectedSuccessFactorOverallRatingId", "Please complete ratings first.")); } } }
public bool IsManagerSigned(PDReview pdr) { return((!string.IsNullOrEmpty(pdr.ManagerSigned)) && pdr.ManagerSignedDate.HasValue); }
public bool IsColleagueSigned(PDReview pdr) { return((!string.IsNullOrEmpty(pdr.ColleagueSigned)) && pdr.ColleagueSignedDate.HasValue); }
public void AcceptUnLockRequest(ApplicationUser loggedInUser, ApplicationUser requestedUser, PDReview pdr) { UnLockPDR(loggedInUser, pdr); LockPDR(requestedUser, pdr); pdr.AccessResponse = requestedUser.Id; UpdatePDR(pdr); }
public bool IsLockedByCurrentUser(ApplicationUser loggedInUser, PDReview pdr) { return(pdr.IsLocked && (loggedInUser.UserName == pdr.LockedBy)); }
public bool IsLocked(ApplicationUser loggedInUser, PDReview pdr) { return(pdr.IsLocked && (pdr.LockEndTime >= DateTime.UtcNow)); }
public void UpdatePDR(PDReview pdr) { _PDRReviewRepository.Update(pdr); SavePDR(); }