public async Task<ActionResult> EditPosition(string id) { Position editPosition = new Position(); using (ApplicationContext context = new ApplicationContext()) { var position = await context.Positions.FindAsync(id); editPosition.Id = position.Id; editPosition.Name = position.Name; } return View("Edit/EditPosition", editPosition); }
public async Task<ActionResult> EditPosition(Position model) { using (ApplicationContext context = new ApplicationContext()) { var position = await context.Positions.FindAsync(model.Id); context.Entry(position).CurrentValues.SetValues(model); context.SaveChanges(); } return RedirectToAction("Positions"); }
public ActionResult CreatePosition(Position model) { if (ModelState.IsValid) { using (ApplicationContext context = new ApplicationContext()) { context.Positions.Add(new Position() { Id = "", Name = model.Name }); context.SaveChanges(); } } return RedirectToAction("Positions"); }