public ActionResult Edit(int?id, authortable author) { try { using (aptadbEntities aptadb = new aptadbEntities()) { //return View(aptadb.authortable.Where(x => x.authorid == id).FirstOrDefault()); aptadb.Entry(author).State = EntityState.Modified; aptadb.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(authortable author) { try { using (aptadbEntities aptadb = new aptadbEntities()) { aptadb.authortable.Add(author); aptadb.SaveChanges(); //return View(aptadb.authortable.ToList()); } // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here using (aptadbEntities aptadb = new aptadbEntities()) { //aptadb.authortable.Add(author); authortable authortable = aptadb.authortable.Where(x => x.authorid == id).FirstOrDefault(); aptadb.authortable.Remove(authortable); aptadb.SaveChanges(); //return View(aptadb.authortable.ToList()); } return(RedirectToAction("Index")); } catch { return(View()); } }