Example #1
0
        /// <summary>
        /// Handles updating and inserting employee salaries
        /// </summary>
        /// <param name="id"></param>
        /// <param name="salary"></param>
        /// <returns></returns>
        public Compensation UpsertCompensation(string id, decimal salary)
        {
            Employee empl = GetById(id);

            if (empl != null)
            {
                Compensation comp = _employeeRepository.GetCompensationById(id);
                if (comp == null)
                {
                    comp = _employeeRepository.AddCompensation(new Compensation()
                    {
                        Employee      = empl,
                        Salary        = salary,
                        EffectiveDate = DateTime.Now,
                    });
                }
                else
                {
                    comp.Salary = salary;
                    _employeeRepository.UpdateCompensation(comp);
                }
                _employeeRepository.SaveAsync().Wait();
                return(comp);
            }
            return(null);
        }
Example #2
0
 public Compensation CreateCompensation(Compensation compensation)
 {
     if (compensation != null)
     {
         _employeeRepository.AddCompensation(compensation);
         _employeeRepository.SaveAsync().Wait();
     }
     return(compensation);
 }