public IActionResult Destroy(int LPId) { LizzardPirate walkThePlank = _context.LizzardCrew.FirstOrDefault(l => l.LizzardPirateId == LPId); _context.LizzardCrew.Remove(walkThePlank); _context.SaveChanges(); return(Redirect("/")); }
public IActionResult Create(LizzardPirate newLP) { if (ModelState.IsValid) { _context.LizzardCrew.Add(newLP); _context.SaveChanges(); return(RedirectToAction("Index")); } else { return(View("Add")); } }
public IActionResult Update(int LPId, LizzardPirate update) { LizzardPirate retrieved = _context.LizzardCrew.FirstOrDefault(l => l.LizzardPirateId == LPId); if (ModelState.IsValid) { retrieved.Name = update.Name; retrieved.LizzardType = update.LizzardType; retrieved.PirateRole = update.PirateRole; retrieved.UpdatedAt = DateTime.Now; _context.SaveChanges(); return(Redirect($"/{LPId}")); } else { update.LizzardPirateId = LPId; return(View("Edit", update)); } }
public IActionResult Edit(int LPId) { LizzardPirate edit = _context.LizzardCrew.FirstOrDefault(l => l.LizzardPirateId == LPId); return(View(edit)); }
public IActionResult Show(int LPId) { LizzardPirate show = _context.LizzardCrew.FirstOrDefault(l => l.LizzardPirateId == LPId); return(View(show)); }