public ActionResult AddLot(Lot _lot) { using (var db = new BaseDataContext()) { if (_lot.ExpirationDateTime == null) { DateTime dt = DateTime.Today; dt.AddDays(5); _lot.ExpirationDateTime = dt; } db.Lots.Add(_lot); db.SaveChanges(); } return RedirectToRoute(new {controller="List",action="ViewList" });//!!!!!!!!!!!!!!!! }
public ActionResult EditLot(Lot _lot) { using (var db = new BaseDataContext()) { db.Entry(_lot).State = EntityState.Modified; try { db.SaveChanges(); return RedirectToRoute(new { controller = "List", action = "ViewList" }); } catch (DbEntityValidationException ex) { foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors) { Response.Write("Object: " + validationError.Entry.Entity.ToString()); foreach (DbValidationError err in validationError.ValidationErrors) { Response.Write(" "); Response.Write(err.ErrorMessage + ""); } } }; return View(); } }
public ActionResult EditLot(Lot _lot) { using (var db = new BaseDataContext()) { db.Entry(_lot).State = EntityState.Modified; db.SaveChanges(); } return RedirectToRoute(new { controller = "List", action = "ViewList" }); }