public StockItemsStatusController(StockItemContext context)
        {
            this.context = context;

            if (!context.StockItems.Any())
            {
                context.StockItems.Add(new StockItem()
                {
                    Id = 1, InStock = true, ProductId = 1
                });
                context.SaveChanges();
            }
        }
Esempio n. 2
0
 public ActionResult EditUnitOfSale(int id, UnitOfSale unitOfSales)
 {
     try
     {
         using (StockItemContext stockItem = new StockItemContext())
         {
             stockItem.Entry(unitOfSales).State = EntityState.Modified;
             stockItem.SaveChanges();
         }
         return(RedirectToAction("UnitOfSaleIndex"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 3
0
 public ActionResult EditSup(int id, Supplier suppliers)
 {
     try
     {
         using (StockItemContext stockItem = new StockItemContext())
         {
             stockItem.Entry(suppliers).State = EntityState.Modified;
             stockItem.SaveChanges();
         }
         return(RedirectToAction("SupplierIndex"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 4
0
        public ActionResult Create(StockItem StockItem)
        {
            try
            {
                using (StockItemContext stockItem = new StockItemContext())
                {
                    stockItem.StockItems.Add(StockItem);
                    stockItem.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 5
0
        public ActionResult CreateUnitOfSale(UnitOfSale unitOfSale)
        {
            try
            {
                using (StockItemContext stockItem = new StockItemContext())
                {
                    stockItem.UnitOfSales.Add(unitOfSale);
                    stockItem.SaveChanges();
                }

                return(RedirectToAction("UnitOfSaleIndex"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 6
0
        public ActionResult CreateSup(Supplier supplier)
        {
            try
            {
                using (StockItemContext stockItem = new StockItemContext())
                {
                    stockItem.Suppliers.Add(supplier);
                    stockItem.SaveChanges();
                }

                return(RedirectToAction("SupplierIndex"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 7
0
        public ActionResult DeleteUnitOfSale(int id, FormCollection collection)
        {
            try
            {
                using (StockItemContext stockItemContext = new StockItemContext())
                {
                    UnitOfSale unitOfSale = stockItemContext.UnitOfSales.Where(x => x.UoSId == id).FirstOrDefault();
                    stockItemContext.UnitOfSales.Remove(unitOfSale);
                    stockItemContext.SaveChanges();
                }

                return(RedirectToAction("UnitOfSaleIndex"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 8
0
        public ActionResult DeleteSup(int id, FormCollection collection)
        {
            try
            {
                using (StockItemContext stockItemContext = new StockItemContext())
                {
                    Supplier suppliers = stockItemContext.Suppliers.Where(x => x.SupId == id).FirstOrDefault();
                    stockItemContext.Suppliers.Remove(suppliers);
                    stockItemContext.SaveChanges();
                }

                return(RedirectToAction("SupplierIndex"));
            }
            catch
            {
                return(View());
            }
        }