public string Delete(int id) { BookModel book = new BookModel(); book.Delete(id); var response = new { resp = "Registro deletado com sucesso, no id " + id }; JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(response)); }
public static bool Delete(string id) { int affectedRows = 0; //if affectedRows isn't 0, then the query has been successfull affectedRows = BookModel.Delete(id); if (affectedRows == 0) { return(false); } else { return(true); } }
public IActionResult DeleteBook(int id) { if (ModelState.IsValid) { var model = new BookModel(); try { var title = model.Delete(id); model.Response = new ResponseModel($"Book {title} successfully deleted.", ResponseType.Success); return(RedirectToAction("Index")); } catch (Exception ex) { model.Response = new ResponseModel("Book delete failued.", ResponseType.Failure); // error logger code } } return(RedirectToAction("index")); }