Esempio n. 1
0
 private void ValidateContract(CreateConsultantContract contract)
 {
     try
     {
         _createConsultantContractValidator.ValidateAndThrow(contract,
                                                             $"{ValidatorConstants.RULESET_CREATE}");
     }
     catch (ValidationException ex)
     {
         throw new CreateContractInvalidException(ex.ToListOfMessages());
     }
 }
Esempio n. 2
0
        public CreatedConsultantContract Create(CreateConsultantContract contract)
        {
            _logger.LogInformation($"Validating contract {contract.Name}");
            ValidateContract(contract);
            ValidateExistence(0, contract.EmailAddress);

            _logger.LogInformation($"Mapping contract {contract.Name}");
            var consultant = _mapper.Map <Consultant>(contract);

            var createdConsultant = _consultantRepository.Create(consultant);

            _logger.LogInformation($"Complete for {contract.Name}");
            _unitOfWork.Complete();
            _logger.LogInformation($"Return {contract.Name}");
            return(_mapper.Map <CreatedConsultantContract>(createdConsultant));
        }