public ActionResult Edit(int id) { PostMachine postMachine = context.PostMachine.Single(emp => emp.IdPostMachine == id); ViewData["FkAddressidAddress"] = GetAddressList(); ViewData["FkLoggedInUseridEndUser"] = GetUseridEndUser("Courier"); ViewData["FkLoggedInUseridEndUser1"] = GetUseridEndUser("Worker"); return(View(postMachine)); }
public ActionResult Edit(PostMachine postMachine) { if (ModelState.IsValid) { context.Update(postMachine); context.SaveChangesAsync(); // not async works return(RedirectToAction(nameof(Index))); } return(View(postMachine)); }
public ActionResult Create([Bind("TurnedOn,PostMachineState,IdPostMachine,FkLoggedInUseridEndUser,FkLoggedInUseridEndUser1,FkAddressidAddress")] PostMachine package) { if (ModelState.IsValid) { package.TurnedOn = false; package.PostMachineState = "WaitsForMaintenance"; int id = context.PostMachine.Max(p => p.IdPostMachine) + 1; package.IdPostMachine = id; context.Add(package); context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FkAddressidAddress"] = GetAddressList(); ViewData["FkLoggedInUseridEndUser"] = GetUseridEndUser("Courier"); ViewData["FkLoggedInUseridEndUser1"] = GetUseridEndUser("Worker"); return(View(package)); }