Пример #1
0
        public IActionResult CreatePayCheck(Guid empId)
        {
            var employeeFromRepo = _appRepository.GetEmployee(empId);

            if (employeeFromRepo == null)
            {
                return(NotFound());
            }

            var payCheckEntity = PayCalculator.GeneratePayCheck(employeeFromRepo);

            _appRepository.AddPayCheck(payCheckEntity);

            if (!_appRepository.Save())
            {
                throw new Exception($"Creation of pay check for employee {empId} failed on save.");
            }

            var payCheckToReturn = Mapper.Map <PayCheckDto>(payCheckEntity);

            return(CreatedAtRoute("GetPayCheck", new { empId = employeeFromRepo.EmpId, txnId = payCheckEntity.TxnId }, payCheckToReturn));
        }