public ActionResult Login(Admin objchk) { if (ModelState.IsValid) { using (PecuniaBankEntities db = new PecuniaBankEntities()) { var obj = db.Admins.Where(a => a.Username.Equals(objchk.Username) && a.Password.Equals(objchk.Password)).FirstOrDefault(); if (obj != null) { Session["Username"] = obj.Username.ToString(); Session["Password"] = obj.Password.ToString(); //objchk.LoginErrorMsg = "Login Successfully."; //return View("Login", objchk); return(RedirectToAction("Main", "Admin")); } else { ModelState.AddModelError("", "The Account_number or password is incorrect"); } } } return(View(objchk)); }
public ActionResult Register(RegisterTable Rg) { using (PecuniaBankEntities DB = new PecuniaBankEntities()) //create an instance for table name to adding the data in the table { DB.RegisterTables.Add(Rg); //Add the data in table DB.SaveChanges(); //save the data } ModelState.Clear(); ViewBag.SuccessMessage = "Registration Successfully."; return(View("Register", new RegisterTable())); }