Exemplo n.º 1
0
 public async Task<ActionResult> Create(Speaker speaker)
 {
     if (ModelState.IsValid)
     {
         _context.Speakers.Add(speaker);
         await _context.SaveChangesAsync();
         return RedirectToAction("Index");
     }
     return View(speaker);
 }
Exemplo n.º 2
0
 public async Task<ActionResult> Edit(int id, Speaker speaker)
 {
     try
     {
         speaker.SpeakerId = id;
         _context.Speakers.Attach(speaker);
         _context.Entry(speaker).State = EntityState.Modified;
         await _context.SaveChangesAsync();
         return RedirectToAction("Index");
     }
     catch (Exception)
     {
         ModelState.AddModelError(string.Empty, "Unable to save changes.");
     }
     return View(speaker);
 }