public async Task<ActionResult> Create(Option option) { if (ModelState.IsValid) { _context.Options.Add(option); await _context.SaveChangesAsync(); return RedirectToAction("Index"); } return View(option); }
public async Task<ActionResult> Edit(int id, Option option) { try { option.OptionId = id; _context.Options.Attach(option); _context.Entry(option).State = EntityState.Modified; await _context.SaveChangesAsync(); return RedirectToAction("Index"); } catch (Exception) { ModelState.AddModelError(string.Empty, "Unable to save changes."); } return View(option); }