Exemple #1
0
        //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();
                }
            }
        }
Exemple #2
0
 public IEnumerable <ValidationResult> CanSavePersonalDevelopmentPlan(PersonalDevelopmentPlan personalDevelopmentPlan)
 {
     yield return(new ValidationResult("SelectedObjectiveOverallRatingId", "Make sure mid year rating is complete/save before saving overall objective."));
 }
Exemple #3
0
 public void UpdatePersonalDevelopmentPlan(PersonalDevelopmentPlan personalDevelopmentPlan)
 {
     _IPersonalDevelopmentPlanRepository.Update(personalDevelopmentPlan);
     SavePDR();
 }