Example #1
0
 private List <JobHistoryEntity> removeElement(JobHistoryEntity oldElement, List <JobHistoryEntity> oldJhs)
 {
     foreach (JobHistoryEntity oldJh in oldJhs)
     {
         if (oldJh.DepartmentId == oldElement.DepartmentId)
         {
             oldJhs.Remove(oldElement);
             break;
         }
     }
     return(oldJhs);
 }
Example #2
0
        private bool isExitsElement(JobHistoryEntity jobHistoryEntity, List <JobHistoryEntity> jhs)
        {
            bool result = false;

            foreach (JobHistoryEntity jh in jhs)
            {
                if (jh.DepartmentId == jobHistoryEntity.DepartmentId)
                {
                    result = true;
                    break;
                }
            }

            return(result);
        }
Example #3
0
        public JobHistoryDetailDTO DoSalaryIncreasing(long empId, int jobLevel)
        {
            var transaction = _humanManagerContext.Database.BeginTransaction();

            try
            {
                DateTime       today          = System.DateTime.Today;
                EmployeeEntity employeeEntity = _humanManagerContext.Employees.Where(e => e.Id == empId)
                                                .Include(e => e.Job)
                                                .ThenInclude(j => j.JobLevel)
                                                .SingleOrDefault();

                JobHistoryEntity jobHistoryEntity = _humanManagerContext.JobHistorys.Where(jh => jh.EmployeeId == employeeEntity.Id && jh.JobId == employeeEntity.JobId).SingleOrDefault();

                // Kiểm tra việc tính lương. tính r ko đc nâng.
                bool haveCounted = _humanManagerContext.SalaryHistories.Where(sh => sh.EmployeeId == empId && sh.CountedDate.Month == today.Month && sh.CountedDate.Year == today.Year).Any();
                if (haveCounted)
                {
                    throw new Exception(SalaryMessageContant.SALARY_COUNTED);
                }

                // kiểm tra và thay đổi job level
                JobLevelEntity jobLevelEntity = employeeEntity.Job.JobLevel;
                if (JobUtil.IsLevelExit(jobLevelEntity, jobLevel))
                {
                    employeeEntity.JobLevel = jobLevel;
                }
                else
                {
                    throw new Exception(SalaryMessageContant.JOB_LEVEL_NOT_EXITS);
                }

                // lưu level vào lịch sử
                _humanManagerContext.JobHistoryDetails.Add(new JobHistoryDetailEntity(jobLevel, today, jobHistoryEntity));
                _humanManagerContext.SaveChanges();

                transaction.Commit();

                return(new JobHistoryDetailDTO(employeeEntity.Id, employeeEntity.Firstname + employeeEntity.Firstname, employeeEntity.JobId, employeeEntity.Job.JobTitle, jobLevel, System.DateTime.Today));
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }
        }
Example #4
0
 private List <JobHistoryEntity> addNewElement(JobHistoryEntity newElement, List <JobHistoryEntity> oldJhs)
 {
     oldJhs.Add(newElement);
     return(oldJhs);
 }