public async Task <CreateItemResponse> Handle( CreateItemOptionRequest request, CancellationToken cancellationToken) { var option = await _optionRepository.GetByIdAsync(request.IdOption); if (option == null) { _notificationContext.AddNotification("Option null", "Opção não encontrada"); return(null); } var item = new Item(request.ItemName, option); item.HasOne(option); if (item.Invalid) { _notificationContext.AddNotifications(item.ValidationResult); return(null); } await _itemRepository.CreateAsync(item); return((CreateItemResponse)item); }
public async Task <PutOptionItemResponse> Handle(PutOptionItemRequest request, CancellationToken cancellationToken) { var option = await _optionRepository.GetByIdAsync(request.IdOption); if (option == null) { _notificationContext.AddNotification("Option null", "Opção não encontrada"); return(null); } var item = await _itemRepository.GetByIdAsync(request.IdItem); if (item == null) { _notificationContext.AddNotification("Item null", "Item não encontrado"); return(null); } item.HasOne(option); return(new PutOptionItemResponse(item, option)); }
public async Task <PutProductOptionResponse> Handle( PutProductOptionRequest request, CancellationToken cancellationToken) { var product = await _productRepository.GetByIdAsync(request.IdProduct); if (product == null) { _notificationContext.AddNotification("Product null", "Produto não encontrado"); return(null); } var option = await _optionRepository.GetByIdAsync(request.IdOption); if (option == null) { _notificationContext.AddNotification("Option null", "Opção não encontrada"); return(null); } product.HasOne(option); return(new PutProductOptionResponse(product, option)); }