public ActionResult Login(tableUser login) { if (db.tableUser.Any(x => x.UserName == login.UserName && x.Password == login.Password)) //kullanıcının girdiği veri, veritabanından kontrol ediliyor { var usr = db.tableUser.FirstOrDefault(x => x.UserName == login.UserName && x.Password == login.Password); Session["UserID"] = usr.ID; Session["UserName"] = usr.UserName; Session["UserType"] = usr.UserType; return(RedirectToAction("ProductList", "Product")); } return(View()); }
public ActionResult Register(tableUser register) { register.UserType = false; db.tableUser.Add(register); db.SaveChanges(); int userId = db.tableUser.ToList().Last().ID; tableWallet tableWallet = new tableWallet() { Money = 0, UserID = userId }; db.tableWallet.Add(tableWallet); db.SaveChanges(); return(RedirectToAction("Login")); }