public ActionResult Bank_add(ETBank Bank) { TempData["messagealert"] = string.Empty; ViewBag.messagealert = string.Empty; if (ModelState.IsValid) { if (Bank != null) { if (repBank.AccountNumberIsExist(Bank.AccountNumber, 0)) { ViewBag.messagealert = "Account Number already exist"; ViewBag.AccountTypes = repBank.getDataValues("AccountType", Session["UserLevel"].ToString(), Convert.ToInt64(Session["UserID"]), Convert.ToInt64(Session["ReportingUser"])); return(View(Bank)); } else if (Bank.CustomerID != null && Bank.CustomerID != "" && repBank.CustomerIDIsExist(Bank.CustomerID, 0)) { ViewBag.messagealert = "Customer ID already exist"; ViewBag.AccountTypes = repBank.getDataValues("AccountType", Session["UserLevel"].ToString(), Convert.ToInt64(Session["UserID"]), Convert.ToInt64(Session["ReportingUser"])); return(View(Bank)); } else if (repBank.BankEmailIsExist(Bank.Email, Convert.ToInt64(Session["UserID"])) || !Common.IsValidEmail(Bank.Email)) { if (!Common.IsValidEmail(Bank.Email)) { ViewBag.messagealert = "Please Enter Valid Email"; } else { ViewBag.messagealert = "Email already exist"; } ViewBag.AccountTypes = repBank.getDataValues("AccountType", Session["UserLevel"].ToString(), Convert.ToInt64(Session["UserID"]), Convert.ToInt64(Session["ReportingUser"])); return(View(Bank)); } else { Bank.UserID = Convert.ToInt64(Session["UserID"]); Bank.CreatedBy = Convert.ToInt64(Session["UserID"]); Bank.CreatedDate = DateTime.Now; Bank.ModifiedBy = Convert.ToInt64(Session["UserID"]); Bank.ModifiedDate = DateTime.Now; dbEntities.ETBanks.Add(Bank); dbEntities.SaveChanges(); if (Bank.BankID != 0) { TempData["messagealert"] = Status.Save; } } } return(RedirectToAction("Index", "Bank")); } return(View()); }