public IHttpActionResult SaveSeflAppraisal(ObjectiveMain main)
        {
            try
            {
                if (main == null)
                {
                    return(BadRequest(ActionMessage.NullOrEmptyMessage));
                }

                Validation   validation = new Validation(new UnitOfWork());
                JobObjective employees  = new JobObjective(new UnitOfWork());
                employees.CreatedBy = User.Identity.GetUserName();
                if (main.Id == Guid.Empty)
                {
                    return(BadRequest("Objective main id can't be null"));
                }

                if (validation.IsSelfAppraisalDeadLineNull(employees.CreatedBy))
                {
                    return(BadRequest("Your self appraisal deadline set  yet by your supervisor!"));
                }

                if (!validation.IsSelfAppraisalDeadLineValid(employees.CreatedBy))
                {
                    return(BadRequest("You have missed your deadline"));
                }

                employees.InsertSeflAppraisalToMain(main);
                return(Ok("You are successfully submitted self appraisal to " + employees.GetReportTo(employees.CreatedBy)));
            }
            catch (Exception exception)
            {
                return(BadRequest(exception.Message));
            }
        }
Example #2
0
        private void InsertObjectiveSub(ObjectiveSub sub)
        {
            var mainId =
                GetUnitOfWork()
                .ObjectiveMainRepository.Get()
                .Where(a => a.EmployeeId == CreatedBy && a.IsActive == true)
                .Select(s => s.Id)
                .FirstOrDefault();
            int weight = 0;

            if (mainId != Guid.Empty)
            {
                weight = GetUnitOfWork().ObjectiveSubRepository.Get().Where(a => a.ObjectiveMainId == mainId).Sum(s => s.Weight ?? 0) + sub.Weight ?? 0;
            }

            if (sub.Id != null)
            {
                if (weight - sub.Weight > 100)
                {
                    throw new Exception("Weight should not be greater then 100");
                }
                ObjectiveSub ob = GetUnitOfWork().ObjectiveSubRepository.Get().FirstOrDefault(a => a.Id == sub.Id);
                if (ob != null)
                {
                    ob.KPI         = sub.KPI;
                    ob.Note        = sub.Note;
                    ob.Target      = sub.Target;
                    ob.Weight      = sub.Weight;
                    ob.Title       = sub.Title;
                    ob.UpdatedBy   = CreatedBy;
                    ob.UpdatedDate = DateTime.Now;
                }
                GetUnitOfWork().ObjectiveSubRepository.Update(ob);
            }
            else
            {
                if (weight > 100)
                {
                    throw new Exception("Weight should not be greater then 100");
                }
                if (mainId == Guid.Empty)
                {
                    ObjectiveMain main = new ObjectiveMain()
                    {
                        EmployeeId = CreatedBy
                    };
                    InsertObjectiveMain(main);
                    mainId = main.Id;
                }
                sub.CreatedBy           = CreatedBy;
                sub.CreatedDate         = DateTime.Now;
                sub.ObjectiveMainId     = mainId;
                sub.IsObjectiveApproved = false;
                sub.Status = true;
                sub.Id     = UniqueNumber.GenerateUniqueNumber();
                GetUnitOfWork().ObjectiveSubRepository.Insert(sub);
            }
        }
Example #3
0
 private void InsertObjectiveMain(ObjectiveMain main)
 {
     if (main.Id == Guid.Empty)
     {
         main.CreatedBy   = CreatedBy;
         main.CreatedDate = DateTime.Now;
         main.IsActive    = true;
         main.Id          = Guid.NewGuid();
         GetUnitOfWork().ObjectiveMainRepository.Insert(main);
     }
 }
        private void InsertOverScore(ObjectiveMain main)
        {
            ObjectiveMain objectiveMain = GetUnitOfWork().ObjectiveMainRepository.GetById(main.Id);

            objectiveMain.OverallScore            = main.OverallScore ?? 0;
            objectiveMain.OverallComment          = main.OverallComment ?? "";
            objectiveMain.PersonalDevelopmentPlan = main.PersonalDevelopmentPlan ?? "";
            objectiveMain.UpdatedBy   = CreatedBy;
            objectiveMain.CreatedDate = DateTime.Now;
            GetUnitOfWork().ObjectiveMainRepository.Update(objectiveMain);
        }
Example #5
0
        public void InsertSeflAppraisalToMain(ObjectiveMain main)
        {
            var m = GetUnitOfWork().ObjectiveMainRepository.Get().FirstOrDefault(a => a.Id == main.Id);

            if (m != null)
            {
                m.UpdatedBy      = CreatedBy;
                m.UpdatedDate    = DateTime.Now;
                m.OverallScore   = main.OverallScore;
                m.OverallComment = main.OverallComment;
                m.IsActive       = true;
                GetUnitOfWork().ObjectiveMainRepository.Update(m);
                InsertSelfAppraisal(main.ObjectiveSub, main.Id);
            }
            else
            {
                throw new Exception("Objective is not available");
            }
            GetUnitOfWork().Save();
        }
 public void SaveSelfAppraisal(ObjectiveMain main)
 {
     InsertOverScore(main);
     InsertSelfAppraisal(main.ObjectiveSub);
     GetUnitOfWork().Save();
 }