public async Task <PutItemResponse> Handle( PutItemRequest request, CancellationToken cancellationToken) { if (request == null) { _notificationContext.AddNotification("Request", "Request não pode ser nulo"); return(null); } var priceRange = await _priceRangeRepository.GetByIdAsync(request.IdPriceRange); if (priceRange == null) { _notificationContext.AddNotification("PriceRange", "price range não encontrado"); return(null); } var item = await _itemRepository.GetByIdAsync(request.IdItem); if (item == null) { _notificationContext.AddNotification("Item", "Item não encontrado"); return(null); } item.HasOne(priceRange); return(new PutItemResponse(priceRange, item)); }
public async Task <CreatePriceResponse> Handle( CreatePriceRequest request, CancellationToken cancellationToken) { if (request == null) { _notificationContext.AddNotification("Request null", "O request não pode ser nulo"); return(null); } var priceRange = await _priceRangeRepository.GetByIdAsync(request.IdPriceRange); if (priceRange == null) { _notificationContext.AddNotification("Price range", "Price range não encontrado"); return(null); } var price = new Price( request.Start, request.End, request.Value ); if (price.Invalid) { _notificationContext.AddNotifications(price.ValidationResult); return(null); } price.HasOne(priceRange); await _priceRepository.CreateAsync(price); return(new CreatePriceResponse(price.Id, priceRange.Id)); }