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));
            }
        }
        public IHttpActionResult SavePerformanceAppraisal([FromBody] List <PerformanceAppraisalPoco> list)
        {
            try
            {
                if (list == null)
                {
                    return(BadRequest(ActionMessage.NullOrEmptyMessage));
                }
                Validation validation = new Validation(new UnitOfWork());

                var          weight     = list.Sum(a => a.Weight);
                JobObjective activities = new JobObjective(new UnitOfWork());
                activities.CreatedBy = User.Identity.GetUserName();
                if (validation.IsJobObjectiveDeadLineValid(activities.CreatedBy))
                {
                    return(BadRequest("You have missed your deadline"));
                }
                activities.SavePerformanceAppraisal(list);
                return(Ok(ActionMessage.SaveMessage));
            }
            catch (Exception EX_NAME)
            {
                return(BadRequest(EX_NAME.Message));
            }
        }
        public IHttpActionResult SaveObjective([FromBody] ObjectiveSub sub)
        {
            try
            {
                if (sub == null)
                {
                    return(BadRequest(ActionMessage.NullOrEmptyMessage));
                }
                Validation   validation = new Validation(new UnitOfWork());
                JobObjective activities = new JobObjective(new UnitOfWork());
                activities.CreatedBy = User.Identity.GetUserName();

                if (!validation.IsJobDescriptionConfirmed(activities.CreatedBy))
                {
                    return(BadRequest("Your job description is not confirmed by your supervisor!"));
                }

                activities.SaveObjective(sub);
                return(Ok(ActionMessage.SaveMessage));
            }
            catch (Exception EX_NAME)
            {
                return(BadRequest(EX_NAME.Message));
            }
        }
        public IHttpActionResult DeleteObjective(string id)
        {
            try
            {
                if (String.IsNullOrEmpty(id))
                {
                    return(BadRequest(ActionMessage.NullOrEmptyMessage));
                }
                Validation   validation = new Validation(new UnitOfWork());
                JobObjective activities = new JobObjective(new UnitOfWork());

                if (validation.IsApproved(id))
                {
                    return(BadRequest("Your job description is already approved!"));
                }

                activities.DeleteObjective(id);
                return(Ok(ActionMessage.DeleteMessage));
            }
            catch (Exception EX_NAME)
            {
                return(BadRequest(EX_NAME.Message));
            }
        }