public void Update(Invention inventionCategory, InventionDto dto) { inventionCategory.SetCode(dto.Code); inventionCategory.SetName(dto.Name); inventionCategory.Description = dto.Description; inventionCategory.CategoryId = dto.CategoryId; inventionCategory.SetPrice(dto.Price); inventionCategory.Enable = dto.Enable; }
public async Task ValidateAsync(InventionDto inventionCategoryDto) { var byDistinctIdAndCode = _inventionPredicateFactory.CreateByDistinctIdAndCode(inventionCategoryDto.Id, inventionCategoryDto.Code); if (await _unitOfWork.Inventions.AnyAsync(byDistinctIdAndCode)) { throw new BusinessRuleException($"{_aggregateRootName}: code={inventionCategoryDto.Code} already exits"); } var byDistinctIdAndName = _inventionPredicateFactory.CreateByDistinctIdAndName(inventionCategoryDto.Id, inventionCategoryDto.Name); if (await _unitOfWork.Inventions.AnyAsync(byDistinctIdAndName)) { throw new BusinessRuleException($"{_aggregateRootName}: name={inventionCategoryDto.Name} already exits"); } //TODO: if (!_inventionCodesService.Exists(inventionDto.Code) throw new Exception($"Invention code is invalid"); //invention code needs to be validated on external service }