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));
        }
Beispiel #3
0
 public virtual T AddEntity(T t, out Exception ex)
 {
     ex = null;
     try
     {
         DbContext.Add(t);
         DbContext.SaveChanges();
     }
     catch (Exception ex1)
     {
         ex = ex1;
     }
     return(t);
 }
Beispiel #4
0
 protected void Save() => _context.SaveChanges();