public ActionResult DeleteConfirmed(int id) { try { db.UsunCzytelnika(id); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception e) { string message = ""; if (e.InnerException == null) { message = "Podano nieprawidłowe dane wypozyczenia!"; } else { message = e.InnerException.Message; } TempData["message"] = message; return(RedirectToAction("Delete")); } /*using (var context = new BibliotekaEntities()) { * using (DbContextTransaction dbContextTransaction = context.Database.BeginTransaction(IsolationLevel.ReadUncommitted)) { * try { * context.Database.ExecuteSqlCommand( * @"DELETE FROM Wypozyczenie WHERE Wypozyczenie.IdCzytelnik = " + id); * * context.Database.ExecuteSqlCommand( * @"DELETE FROM Czytelnik WHERE Czytelnik.IdCzytelnik = " + id); * * context.SaveChanges(); * * dbContextTransaction.Commit(); * * return RedirectToAction("Index"); * } catch (Exception e) { * string message = ""; * * if (e.InnerException == null) { * message = "Wystąpił błąd przy usuwaniu czytelnika!"; * } else { * message = e.InnerException.Message; * } * * TempData["message"] = message; * return RedirectToAction("Delete"); * } * } * }*/ }