public ActionResult Create([Bind(Include = "ID,Name,UserName,Password")] Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "ID,Name,CustomerID")] Location location) { if (ModelState.IsValid) { db.Location.Add(location); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", location.CustomerID); return(View(location)); }
public ActionResult Create([Bind(Include = "ID,Name,Telephone,CustomerID")] Distributer distributer) { if (ModelState.IsValid) { db.Distributer.Add(distributer); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", distributer.CustomerID); return(View(distributer)); }
public ActionResult Create([Bind(Include = "ID,Name,Active,reOrder,CustomerID")] Item item) { if (ModelState.IsValid) { db.Item.Add(item); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", item.CustomerID); return(View(item)); }
public ActionResult Create([Bind(Include = "ID,name,address,company,telephone,CustomerID")] Supplier supplier) { if (ModelState.IsValid) { db.Supplier.Add(supplier); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", supplier.CustomerID); return(View(supplier)); }
public ActionResult Create([Bind(Include = "ID,Description,Qty,BatchID,CustomerID")] Damage damage) { if (ModelState.IsValid) { db.Damage.Add(damage); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BatchID = new SelectList(db.Batch, "ID", "ID", damage.BatchID); ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", damage.CustomerID); return(View(damage)); }
public ActionResult Create([Bind(Include = "ID,Description,Qty,CustomerID,BatchID,SupplierID")] Return @return) { if (ModelState.IsValid) { db.Return.Add(@return); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.BatchID = new SelectList(db.Batch, "ID", "ID", @return.BatchID); ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", @return.CustomerID); ViewBag.SupplierID = new SelectList(db.Supplier, "ID", "name", @return.SupplierID); return View(@return); }
public ActionResult Create([Bind(Include = "ID,Date,Qty,UnitPrice,ItemID,SupplierID,CustomerID")] Batch batch) { if (ModelState.IsValid) { db.Batch.Add(batch); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", batch.CustomerID); ViewBag.ItemID = new SelectList(db.Item, "ID", "Name", batch.ItemID); ViewBag.SupplierID = new SelectList(db.Supplier, "ID", "name", batch.SupplierID); return(View(batch)); }
public ActionResult Create([Bind(Include = "ID,CustomerID,BatchID,LocationID,DistributerID")] TransferDetail transferDetail) { if (ModelState.IsValid) { db.TransferDetail.Add(transferDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BatchID = new SelectList(db.Batch, "ID", "ID", transferDetail.BatchID); ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", transferDetail.CustomerID); ViewBag.DistributerID = new SelectList(db.Distributer, "ID", "Name", transferDetail.DistributerID); ViewBag.LocationID = new SelectList(db.Location, "ID", "Name", transferDetail.LocationID); return(View(transferDetail)); }
public void ReturnInsertTest() { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Return newReturn = new Return { Description = "Dates are expired", Qty = 2, BatchID = 1, SupplierID = 1 }; newReturn.Batch = new Batch { ID = 1, Date = DateTime.Today, Qty = 50, UnitPrice = 42.00, ItemID = 1, SupplierID = 1 }; newReturn.Supplier = new Supplier { ID = 1, name = "Dhanapala", address = "Galle Road,Kaluwella", company = "Harishchandra", telephone = "077-1234567" }; db.Return.Add(newReturn); db.SaveChanges(); Supplier findSupplier = db.Supplier.Where(C => C.name == "Dhanapala").FirstOrDefault(); Assert.AreEqual(newReturn.Supplier.name, findSupplier.name); //if(findReturn != null) // { // db.Return.Remove(findReturn); // } }
public void BatchInsertTest() { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Batch newBatch = new Batch { Date = DateTime.Today, Qty = 50, UnitPrice = 42.00, ItemID = 1, SupplierID = 1 }; newBatch.Item = new Item { ID = 1, Name = "Dhal", Active = true, reOrder = 10 }; newBatch.Supplier = new Supplier { ID = 1, name = "Dhanapala", address = "Galle Road,Kaluwella", company = "Harishchandra", telephone = "077-1234567" }; db.Batch.Add(newBatch); db.SaveChanges(); Item findItem = db.Item.Where(C => C.Name == "Dhal").FirstOrDefault(); Assert.AreEqual(newBatch.Item.Name, findItem.Name); //if(findBatch != null) //{ // db.Batch.Remove(findBatch); //} }
public void TransferDetailInsertTest() { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); TransferDetail newTransferDetail = new TransferDetail { ID = 1, BatchID = 1, LocationID = 1, DistributerID = 1 }; newTransferDetail.Batch = new Batch { Date = DateTime.Today, Qty = 50, UnitPrice = 42.00, ItemID = 1, SupplierID = 1 }; newTransferDetail.Location = new Location { ID = 1, Name = "Branch" }; newTransferDetail.Distributer = new Distributer { ID = 1, Name = "Lasantha", Telephone = "0717896543" }; db.TransferDetail.Add(newTransferDetail); db.SaveChanges(); Distributer findDistributer = db.Distributer.Where(C => C.Name == "Lasantha").FirstOrDefault(); Assert.AreEqual(newTransferDetail.Distributer.Name, findDistributer.Name); //if(findTransferDetail != null) //{ // db.TransferDetail.Remove(findTransferDetail); //} }
public bool LocationUpdate(int id, Location item) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Location newLocation = db.Location.Find(id); if (newLocation == null) { return(false); } db.Entry(newLocation).State = EntityState.Modified; db.SaveChanges(); return(true); }
public bool BatchUpdate(int id, Batch batch) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Batch newBatch = db.Batch.Find(id); if (newBatch == null) { return(false); } db.Entry(newBatch).State = EntityState.Modified; db.SaveChanges(); return(true); }
public bool SupplierUpdate(int id, Supplier supplier) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Supplier newSupplier = db.Supplier.Find(id); if (newSupplier == null) { return(false); } db.Entry(newSupplier).State = EntityState.Modified; db.SaveChanges(); return(true); }
public bool ReturnUpdate(int id, Return re) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Return newReturn = db.Return.Find(id); if (newReturn == null) { return(false); } db.Entry(newReturn).State = EntityState.Modified; db.SaveChanges(); return(true); }
public bool TransferDetailUpdate(int id, TransferDetail transferDetail) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); TransferDetail newTransferDetail = db.TransferDetail.Find(id); if (newTransferDetail == null) { return(false); } db.Entry(newTransferDetail).State = EntityState.Modified; db.SaveChanges(); return(true); }
public bool DamageUpdate(int id, Damage damage) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Damage newDamage = db.Damage.Find(id); if (newDamage == null) { return(false); } db.Entry(newDamage).State = EntityState.Modified; db.SaveChanges(); return(true); }
public bool ItemUpdate(int id, Item item) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Item newItem = db.Item.Find(id); if (newItem == null) { return(false); } db.Entry(newItem).State = EntityState.Modified; db.SaveChanges(); return(true); }
public bool DistributerDelete(int id) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Distributer distributer = db.Distributer.Find(id); if (distributer == null) { return(false); } db.Distributer.Remove(distributer); db.SaveChanges(); return(true); }
public bool ItemDelete(int id) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Item item = db.Item.Find(id); if (item == null) { return(false); } db.Item.Remove(item); db.SaveChanges(); return(true); }
public bool DamageDelete(int id) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Damage damage = db.Damage.Find(id); if (damage == null) { return(false); } db.Damage.Remove(damage); db.SaveChanges(); return(true); }
public bool LocationDelete(int id) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Location location = db.Location.Find(id); if (location == null) { return(false); } db.Location.Remove(location); db.SaveChanges(); return(true); }
public bool SupplierDelete(int id) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Supplier supplier = db.Supplier.Find(id); if (supplier == null) { return(false); } db.Supplier.Remove(supplier); db.SaveChanges(); return(true); }
public bool DistributerUpdate(int id, Distributer distributer) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Distributer newDistributer = db.Distributer.Find(id); if (newDistributer == null) { return(false); } db.Entry(newDistributer).State = EntityState.Modified; db.SaveChanges(); return(true); }
public bool ReturnDelete(int id) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Return re = db.Return.Find(id); if (re == null) { return(false); } db.Return.Remove(re); db.SaveChanges(); return(true); }
public bool BatchDelete(int id) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Batch batch = db.Batch.Find(id); if (batch == null) { return(false); } db.Batch.Remove(batch); db.SaveChanges(); return(true); }
public bool TransferDetailDelete(int id) { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); TransferDetail transferDetail = db.TransferDetail.Find(id); if (transferDetail == null) { return(false); } db.TransferDetail.Remove(transferDetail); db.SaveChanges(); return(true); }
public void SupplierInsertTest() { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Supplier newSupplier = new Supplier { name = "Dhanapala", address = "Galle Road,Kaluwella", company = "Harishchandra", telephone = "077-1234567" }; db.Supplier.Add(newSupplier); db.SaveChanges(); Supplier findSupplier = db.Supplier.Where(C => C.name == "Dhanapala").FirstOrDefault(); Assert.AreEqual(newSupplier.name, findSupplier.name); //if(findSupplier != null) // { // db.Supplier.Remove(findSupplier); //} }
public void DistributerInsertTest() { OpenQbitInventoryContext db = new OpenQbitInventoryContext(); Distributer newDistributer = new Distributer { Name = "Lasantha", Telephone = "0717896543" }; db.Distributer.Add(newDistributer); db.SaveChanges(); Distributer findDistributer = db.Distributer.Where(C => C.Name == "Lasantha").FirstOrDefault(); Assert.AreEqual(newDistributer.Name, findDistributer.Name); // if(findDistributer != null) //{ // db.Distributer.Remove(findDistributer); //} }