private void ValidateContract(CreateStageContract contract) { try { _createStageContractValidator.ValidateAndThrow(contract, $"{ValidatorConstants.RULESET_CREATE}"); var process = this.GetProcess(contract.ProcessId); var processContract = _mapper.Map <ReadedProcessContract>(process); _processStatusContractValidator.ValidateAndThrow(processContract); } catch (ValidationException ex) { throw new CreateStageInvalidException(ex.ToListOfMessages()); } }
public CreatedStageContract Create(CreateStageContract contract) { _log.LogInformation($"Validating contract {contract.Status}"); ValidateContract(contract); _log.LogInformation($"Mapping contract {contract.Status}"); var stage = _mapper.Map <Stage>(contract); var createdStage = _processStageRepository.Create(stage); _log.LogInformation($"Complete for {contract.Status}"); _unitOfWork.Complete(); var createdStageContract = _mapper.Map <CreatedStageContract>(createdStage); _log.LogInformation($"Return {contract.Status}"); return(createdStageContract); }