Beispiel #1
0
        //   update inventory
        public void InsertOrUpdateInventory(List <PurchaseItem> pi)
        {
            PharmContext dba = new PharmContext();

            foreach (PurchaseItem item in pi)
            {
                dba.PurchaseItemContext.Add(item);
                dba.SaveChanges();
                repo.InsertOrUpdateInventory(item);
            }
        }
Beispiel #2
0
        public JsonResult SavePurchase(PurchaseEntryVM p)
        {
            bool status = false;

            if (p != null)
            {
                DataAccess.Purchase purchase = new DataAccess.Purchase
                {
                    ID          = p.ID,
                    Date        = p.Date,
                    SupplierID  = p.SupplierID,
                    Amount      = p.Amount,
                    Discount    = p.Discount,
                    Tax         = p.Tax,
                    GrandTotal  = p.GrandTotal,
                    IsPaid      = p.IsPaid,
                    Description = p.Description,
                    LastUpdated = DateTime.Now
                };

                purchase.PurchaseItems = new List <PurchaseItem>();
                foreach (var i in p.PurchaseItems)
                {
                    purchase.PurchaseItems.Add(i);
                }

                //add purchase
                Purcrep.Add(purchase);
                PurchaseEntryRepository pent = new PurchaseEntryRepository();
                foreach (var item in p.PurchaseItems)
                {
                    pent.InsertOrUpdateInventory(item);
                }

                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }