public async Task ValidateAsync(InventionCategoryDto inventionCategoryDto) { var byDistinctIdAndName = _inventionCategoryPredicateFactory.CreateByDistinctIdAndName(inventionCategoryDto.Id, inventionCategoryDto.Name); if (await _unitOfWork.Inventions.AnyAsync(byDistinctIdAndName)) { throw new BusinessRuleException($"{_aggregateRootName}: name={inventionCategoryDto.Name} already exits"); } var byDistinctIdAndCode = _inventionCategoryPredicateFactory.CreateByDistinctIdAndCode(inventionCategoryDto.Id, inventionCategoryDto.Code); if (await _unitOfWork.Inventions.AnyAsync(byDistinctIdAndCode)) { throw new BusinessRuleException($"{_aggregateRootName}: code={inventionCategoryDto.Code} already exits"); } }
public void Update(InventionCategory inventionCategory, InventionCategoryDto dto) { inventionCategory.SetCode(dto.Code); inventionCategory.SetName(dto.Name); inventionCategory.SetDescription(dto.Description); }