public JsonResult Add(tbl_loan_type model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_loan_type tbl = new tbl_loan_type(); tbl.code = "0"; tbl.description = model.description; tbl.interest = model.interest; tbl.interest_type = model.interest_type; tbl.days = model.days; db.tbl_loan_type.Add(tbl); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (DataException ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public ActionResult LoadLoanTypeDays(long?id) { using (db_lendingEntities db = new db_lendingEntities()) if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbl_loan_type tbl_loan_type = db.tbl_loan_type.Find(id); if (tbl_loan_type == null) { return(HttpNotFound()); } return(Json(tbl_loan_type.days, JsonRequestBehavior.AllowGet)); }
public ActionResult Add1([Bind(Include = "autonum, code, description, interest, interest_type")] tbl_loan_type model) { try { if (ModelState.IsValid) { db.tbl_loan_type.Add(model); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(model)); }