public int Post(loginModel loginModel) { int id; try { loginDB loginEF = new loginDB() { userName = loginModel.userName, pswrd = loginModel.password, }; // will save data here in database; using (BGEnqiryEntities context = new BGEnqiryEntities()) { //context.homes.Add(loginEF); context.loginDBs.Add(loginEF); context.SaveChanges(); id = loginEF.id; } return(id); } catch (Exception ex) { return(-1); } }
public ActionResult Verify(user acc) { using (loginDB db = new loginDB()) { var userDetail = db.user.Where(x => x.userName == acc.userName && x.userPassword == acc.userPassword).FirstOrDefault(); if (userDetail == null) { acc.LoginErrorMessage = "Kullanıcı adı/parolanızı kontrol ediniz"; return(View("Login", acc)); } else { Session["userID"] = acc.userID; Session["userName"] = acc.userName; return(RedirectToAction("Index", "Home")); } } return(View()); }