private void ValidateContract(CreateSkillContract contract) { try { _createSkillContractValidator.ValidateAndThrow(contract, $"{ValidatorConstants.RULESET_CREATE}"); } catch (ValidationException ex) { throw new CreateContractInvalidException(ex.ToListOfMessages()); } }
public CreatedSkillContract Create(CreateSkillContract contract) { _log.LogInformation($"Validating contract {contract.Name}"); ValidateContract(contract); ValidateExistence(0, contract.Name); _log.LogInformation($"Mapping contract {contract.Name}"); var skill = _mapper.Map <Skill>(contract); this.AddTypeToSkill(skill, contract.Type); var createdSkill = _skillRepository.Create(skill); _log.LogInformation($"Complete for {contract.Name}"); _unitOfWork.Complete(); _log.LogInformation($"Return {contract.Name}"); return(_mapper.Map <CreatedSkillContract>(createdSkill)); }