public OrderCreationProductViewModel(OrderProductSM orderProduct, IBarcodeProducer barcodeProducer, CurrencySettings currencySettings) { _orderProduct = orderProduct; _barcodeProducer = barcodeProducer; _currencySettings = currencySettings; }
public async Task <OrderSM> AddProductAsync(OrderSM order, string barcode, int quantity = 1) { if (order == null) { throw new ArgumentNullException(nameof(order)); } if (barcode == null) { throw new ArgumentNullException(nameof(barcode)); } if (quantity < 1) { throw new ArgumentOutOfRangeException(nameof(quantity), "Quantity should be more positive number."); } OrderSM orderSm; var orderProductSm = order.FirstOrDefault(x => x.Product.Barcode == barcode); if (orderProductSm is null) { var productSm = await _productRack.GetAsync(barcode); if (productSm is null) { return(order); } orderProductSm = new OrderProductSM(productSm) { Quantity = quantity }; orderSm = new OrderSM(order.Session, order.Append(orderProductSm)); } else { orderProductSm.Quantity += quantity; orderSm = new OrderSM(order.Session, order); } orderProductSm.Order = orderSm; return(orderSm); }
public ReceiptRowViewModel(OrderProductSM orderProduct, CurrencySettings currencySettings) { _orderProduct = orderProduct; _currencySettings = currencySettings; }