Exemplo n.º 1
0
        public PurchaseGet(InventoryDbContext context, PurchaseDTO dto) : base(dto)
        {
            ProductDetails = new List <PurchaseProductDetails>();

            string[] productIDs        = dto.ProductIDs.Split(',');
            string[] productQuantities = dto.ProductQuantities.Split(',');
            string[] buyingPrices      = dto.BuyingPrices.Split(',');
            string[] discounts         = dto.Discounts.Split(',');

            if (!((productIDs.Length == productQuantities.Length) && (productQuantities.Length == buyingPrices.Length)))
            {
                Assert.Do("Invalid Purchase Entry!");
            }

            int length = productIDs.Length;

            for (int i = 0; i < length; ++i)
            {
                int    id       = int.Parse(productIDs[i]);
                int    quantity = int.Parse(productQuantities[i]);
                double price    = double.Parse(buyingPrices[i]);
                double discount = double.Parse(discounts[i]);

                ProductGet             product = DataService.GetProductDataController().Get(id);
                PurchaseProductDetails detail  = new PurchaseProductDetails(product, quantity, price, discount);
                ProductDetails.Add(detail);
            }
            if (dto.VendorID != 0)
            {
                Vendor = new VendorGet(context, context.GetVendor(dto.VendorID));
            }
        }
Exemplo n.º 2
0
 public PurchaseProductDetails(ProductGet product, int quantity, double buyingPrice, double discount)
 {
     Product     = product;
     Quantity    = quantity;
     BuyingPrice = buyingPrice;
     Discount    = discount;
 }
 public ProductPost(ProductGet get)
     : base(get)
 {
     CategoryID = get.Category.ID;
 }