public async Task Update(core.Planification plan) { var exist = _context.Planifications.Any(x => x.Id == plan.Id); if (!exist) { await _context.Planifications.AddAsync(plan); } foreach (core.Crop crop in plan.Crops) { switch (crop.State) { case TrackingState.Added: _context.Entry(crop).State = EntityState.Added; break; case TrackingState.Modified: _context.Entry(crop).State = EntityState.Modified; break; case TrackingState.Removed: _context.Entry(crop).State = EntityState.Deleted; break; default: break; } ; } await Uow.SaveChangesAsync(default(CancellationToken)); }
public ActionResult Edit(Plan plan) { if (ModelState.IsValid) { db.Entry(plan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(plan)); }
public ActionResult Edit([Bind(Include = "Id,Note,Date")] Plan plan) { if (ModelState.IsValid) { db.Entry(plan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("AllNote")); } return(View(plan)); }
public ActionResult Delete(int id) { Plan p = new Plan { Id = id }; _context.Entry(p).State = EntityState.Deleted; _context.SaveChanges(); return(RedirectToAction("ListPlans")); }