Beispiel #1
0
 private void ValidateContract(CreateHireProjectionContract contract)
 {
     try
     {
         _createHireProjectionContractValidator.ValidateAndThrow(contract,
                                                                 $"{ValidatorConstants.RULESET_CREATE}");
     }
     catch (ValidationException ex)
     {
         throw new CreateContractInvalidException(ex.ToListOfMessages());
     }
 }
Beispiel #2
0
        public CreatedHireProjectionContract Create(CreateHireProjectionContract contract)
        {
            _log.LogInformation($"Validating contract {contract.Month} + {contract.Year}");
            ValidateContract(contract);
            ValidateExistence(0, contract.Month, contract.Year);

            _log.LogInformation($"Mapping contract {contract.Month} + {contract.Year}");
            var hireProjection = _mapper.Map <HireProjection>(contract);

            var createdHireProjection = _hireProjectionRepository.Create(hireProjection);

            _log.LogInformation($"Complete for {contract.Month} + {contract.Year}");
            _unitOfWork.Complete();
            _log.LogInformation($"Return {contract.Month} + {contract.Year}");
            return(_mapper.Map <CreatedHireProjectionContract>(createdHireProjection));
        }