public ActionResult Create([Bind(Include = "Id,PlantationId,WarehouseId,ScheduledDate,ClosedDate,Status")] Supply supply) { if (ModelState.IsValid) { db.Supplies.Add(supply); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PlantationId = new SelectList(db.Plantations, "Id", "Name", supply.PlantationId); ViewBag.WarehouseId = new SelectList(db.Warehouses, "Id", "Name", supply.WarehouseId); return(View(supply)); }
public ActionResult Create([Bind(Include = "Id,PlantationId,Amount,FlowerId")] PlantationFlower plantationFlower) { if (ModelState.IsValid) { db.PlantationFlowers.Add(plantationFlower); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FlowerId = new SelectList(db.Flowers, "Id", "Name", plantationFlower.FlowerId); ViewBag.PlantationId = new SelectList(db.Plantations, "Id", "Name", plantationFlower.PlantationId); return(View(plantationFlower)); }
public virtual T AddEntity(T t, out Exception ex) { ex = null; try { DbContext.Add(t); DbContext.SaveChanges(); } catch (Exception ex1) { ex = ex1; } return(t); }
protected void Save() => _context.SaveChanges();