public ActionResult Index([Bind(Include = "centerName,password")] center_tb aCenterTb) { try { if (ModelState.IsValid) { int i = aGateway.validation_pass(aCenterTb); if (i == 1) { if (aGateway.getcenterid(aCenterTb) != 0) { TempData["doc1"] = aGateway.getcenterid(aCenterTb); } else { return(View("error1")); } TempData["doc2"] = aCenterTb.centerName; return(View("Center")); } return(View("error1")); } } 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("error1")); }
public ActionResult Create_Center(string districtId, string thanaId, string centerName) { center_tb aCenterTb = new center_tb(); if (districtId != null && thanaId != null && centerName != null) { // System.Web.Security.Membership.GeneratePassword(int length, int numberOfNonAlphanumericCharacters) aCenterTb.centerName = centerName; aCenterTb.districtID = Convert.ToInt32(districtId); aCenterTb.districtName = aGateway.getdisNamebydisId(Convert.ToInt32(districtId)); aCenterTb.thanaID = Convert.ToInt32(thanaId); aCenterTb.thanaName = aGateway.getthanaNamebythanaId(Convert.ToInt32(thanaId)); aCenterTb.password = aGateway.CreatePassword(); aGateway.insert_data(aCenterTb); return(View("Index")); } return(View()); }