public Compensation Create(Compensation compensation)
        {
            if (compensation != null)
            {
                _compensationRepository.Add(compensation);
                _compensationRepository.SaveAsync().Wait();
            }

            return(compensation);
        }
        public async Task <Compensation> Create(Compensation compensation)
        {
            if (compensation != null)
            {
                _compensationRepository.Add(compensation);
                await _compensationRepository.SaveAsync();
            }

            return(compensation);
        }
 public Compensation Create(string id, double salary, DateTime date)
 {
     if (id != null && date != null)
     {
         var comp = _compensationRepository.Add(id, salary, date);
         _compensationRepository.SaveAsync().Wait();
         return(comp);
     }
     return(null);
 }
예제 #4
0
        public Compensation Create(Compensation compensation)
        {
            if (compensation != null)
            {
                compensation.CompensationId = Guid.NewGuid().ToString();
                _compensationRepository.Add(compensation);
                _compensationRepository.SaveAsync().Wait();
            }

            return(compensation);
        }
        public Compensation Create(Compensation compensation)
        {
            if (compensation != null)
            {
                Guid x;
                if (compensation.Salary < 0)
                {
                    throw new Exception("Salary must be greater than zero.");
                }
                else if (String.IsNullOrEmpty(compensation.EmployeeId) || !Guid.TryParse(compensation.EmployeeId, out x))
                {
                    throw new Exception("Must be a valid employee.");
                }

                _compensationRepository.Add(compensation);
                _compensationRepository.SaveAsync().Wait();
            }

            return(compensation);
        }
        public Compensation createCompensation(Compensation compensation)

        {
            if (compensation != null && compensation.Employee != null)
            {
                _compensationRepository.createCompensation(compensation);
                _compensationRepository.SaveAsync().Wait();
            }

            return(compensation);
        }
예제 #7
0
        /// <summary>
        /// This method will create a compensation record for the employee on the request if they exist
        /// </summary>
        /// <param name="compensation"></param>
        /// <returns></returns>
        public Compensation Create(Compensation compensation)
        {
            if (compensation == null)
            {
                throw new ArgumentException("compensation is null.");
            }

            _compensationRepository.Add(compensation);
            _compensationRepository.SaveAsync().Wait();

            return(compensation);
        }
예제 #8
0
        public Compensation Create(Compensation compensation)
        {
            if (compensation == null || string.IsNullOrWhiteSpace(compensation.EmployeeId))
            {
                return(null);
            }

            _compensationRepository.Add(compensation);
            _compensationRepository.SaveAsync().Wait();

            return(_compensationRepository.GetByEmployeeId(compensation.EmployeeId));
        }
        public Compensation Create(Compensation compensation)
        {
            if (compensation != null)
            {
                _compensationRepository.Add(compensation);
                _compensationRepository.SaveAsync().Wait();
            }

            //avoid json self referencing loop
            compensation.Employee = null;

            return(compensation);
        }
예제 #10
0
        public Compensation Create(Compensation compensation)
        {
            if (compensation != null)
            {
                // Make sure the employee exists since the in memory provider does not enforce a required foreign key
                var employee = _employeeRepository.GetById(compensation.Employee);
                if (employee == null)
                {
                    return(null);
                }

                _compensationRepository.Add(compensation);
                _compensationRepository.SaveAsync().Wait();
            }

            return(compensation);
        }
예제 #11
0
        public Compensation CreateCompensation(Compensation compensation)
        {
            if (compensation == null ||
                compensation.Employee == null)
            {
                return(null);
            }

            _logger.LogDebug("Received creating compensation.");

            // Retrieve existing employee
            // If not found null is returned.
            Employee employee = _employeeRepository.GetById(compensation.Employee.EmployeeId);

            if (employee == null)
            {
                return(null);
            }

            _logger.LogDebug($"Creating Compensation. Employee Id:{employee.EmployeeId}");

            //Build compensation object
            Compensation newCompensation = new Compensation
            {
                CompensationId = Guid.NewGuid().ToString(),
                Employee       = employee,
                EffectiveDate  = compensation.EffectiveDate,
                Salary         = compensation.Salary
            };

            // Save
            _compensationRepository.Add(newCompensation);
            _compensationRepository.SaveAsync().Wait();
            _logger.LogDebug($"Compensation Saved. Id:{newCompensation.CompensationId}");

            return(newCompensation);
        }