public async Task <ValidationResult> Handle(UpdatePriceCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { return(request.ValidationResult); } var existingItem = await _itemRepository.FindById(request.ItemId); if (existingItem == null) { AddError("Item not found."); return(ValidationResult); } existingItem.UpdateValues(request.InCashValue, request.NormalValue, request.FullValue); existingItem.SetAvailability(request.IsAvailable); var history = new ItemHistory(request.ItemId, request.InCashValue, request.NormalValue, request.FullValue, request.IsAvailable); _itemRepository.AddHistory(history); existingItem.AddEvent(new PriceUpdatedEvent(request.ItemId, request.InCashValue, request.NormalValue, request.FullValue, request.IsAvailable)); return(await Persist(_itemRepository.UnitOfWork)); }