Ejemplo n.º 1
0
 public OrderCreationProductViewModel(OrderProductSM orderProduct,
                                      IBarcodeProducer barcodeProducer,
                                      CurrencySettings currencySettings)
 {
     _orderProduct     = orderProduct;
     _barcodeProducer  = barcodeProducer;
     _currencySettings = currencySettings;
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public ReceiptRowViewModel(OrderProductSM orderProduct, CurrencySettings currencySettings)
 {
     _orderProduct     = orderProduct;
     _currencySettings = currencySettings;
 }