예제 #1
0
        public async Task <Unit> Handle(UpdateFoodProductCommand command, CancellationToken cancellationToken)
        {
            var foodProduct = await _foodProductRepository.GetByIdAsync(command.FoodProductId);

            foodProduct.UpdateProductName(command.FoodProductName);

            await _unitOfWork.CommitAsync(cancellationToken);

            return(Unit.Value);
        }
예제 #2
0
        public async Task <Unit> Handle(AddFridgeItemCommand command, CancellationToken cancellationToken)
        {
            var fridge = await _fridgeRepository.GetByIdAsync(command.FridgeId);

            var user = fridge.GetFridgeUser(command.UserId);

            var foodProduct = await _foodProductRepository.GetByIdAsync(command.FridgeItemDto.FoodProductId);

            var fridgeItem = new FridgeItem(
                foodProduct.FoodProductId,
                command.FridgeItemDto.Note,
                new AmountValue(
                    command.FridgeItemDto.Value,
                    command.FridgeItemDto.Unit)
                );

            user.AddFridgeItem(fridgeItem);

            await _unitOfWork.CommitAsync(cancellationToken);

            return(Unit.Value);
        }