Exemplo n.º 1
0
 protected POSOrderItem(Product product, POSOrder posOrder, int quantity)
 {
     ProductUniqueCode = product.UniqueCode;
     CustomerValue     = product.EndCustomerPrice;
     CostPrice         = product.CostPrice;
     POSOrderId        = posOrder.Id;
     Quantity          = quantity;
 }
Exemplo n.º 2
0
        public static BaseResult <POSOrderItem> Create(int productId, int quantity, POSOrder posOrder, IRepository <Product> productRepository)
        {
            var product = productRepository.GetBy(productId);

            if (product.QuantityInStock == 0)
            {
                return(BaseResult <POSOrderItem> .Failed(new [] { $"can't create item.Product of id {product.Id} is out of stock" }, null));
            }
            if ((product.QuantityInStock - quantity) < 0)
            {
                return(BaseResult <POSOrderItem> .Succeed("Order Item is defined", new POSOrderItem(product, posOrder, product.QuantityInStock)));
            }
            var item = new POSOrderItem(product, posOrder, quantity);

            return(BaseResult <POSOrderItem> .Succeed("Order Item is defined", item));
        }