public ActionResult Create([Bind(Include = "ID_Repayment,FK_Credit,Date_of_Repayment,Fair_Sum,Sum_of_Repayment")] Credit_Repayment credit_Repayment) { if (ModelState.IsValid) { try { db.Credit_Repayment.Add(credit_Repayment); db.SaveChanges(); return(RedirectToAction("Index")); } catch (DbUpdateException ex) { var sqlexception = ex.GetBaseException() as SqlException; // определяем SqlException if (sqlexception != null) { if (sqlexception.Errors.Count > 0) { if (sqlexception.Errors[0].Class == 15) // В случае если состояние RAISERROR в триггере = 15, то получаем следующее сообщение { ViewBag.message = "Некорректная дата кредита!"; } else if (sqlexception.Errors[0].Class == 16) // В случае если состояние RAISERROR в триггере 16, то получаем следующее сообщение { ViewBag.message = "Вы не можете делать двойные взносы за один месяц!"; } } } } } ViewBag.FK_Credit = new SelectList(db.Credit_Info, "ID_Credit", "Credit_Description", credit_Repayment.FK_Credit); return(View(credit_Repayment)); }
public ActionResult DeleteConfirmed(int id) { Credit_Repayment credit_Repayment = db.Credit_Repayment.Find(id); db.Credit_Repayment.Remove(credit_Repayment); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID_Repayment,FK_Credit,Date_of_Repayment,Fair_Sum,Sum_of_Repayment")] Credit_Repayment credit_Repayment) { if (ModelState.IsValid) { db.Entry(credit_Repayment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FK_Credit = new SelectList(db.Credit_Info, "ID_Credit", "Credit_Description", credit_Repayment.FK_Credit); return(View(credit_Repayment)); }
// GET: Credit_Repayment/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Credit_Repayment credit_Repayment = db.Credit_Repayment.Find(id); if (credit_Repayment == null) { return(HttpNotFound()); } return(View(credit_Repayment)); }
// GET: Credit_Repayment/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Credit_Repayment credit_Repayment = db.Credit_Repayment.Find(id); if (credit_Repayment == null) { return(HttpNotFound()); } ViewBag.FK_Credit = new SelectList(db.Credit_Info, "ID_Credit", "Credit_Description", credit_Repayment.FK_Credit); return(View(credit_Repayment)); }