public ActionResult Index(string email, string password) { if (String.IsNullOrEmpty(password) || String.IsNullOrEmpty(email)) { ViewBag.msg = "Empty input"; return(View()); } UserManager userManager = new UserManager(); User userToLogIn = userManager.LogIn(email, password); if (userToLogIn != null) { ViewBag.msg = "Log In Successfully"; //ViewBag.user = userToLogIn; SetSession.SetUser(userToLogIn); return(RedirectToAction("index", "HomePage")); } else { ViewBag.msg = "Wrong Password or E-Mail"; } return(View()); }
public ActionResult Index(User user) { if (String.IsNullOrEmpty(user.Name) || String.IsNullOrEmpty(user.Password) || String.IsNullOrEmpty(user.Status)) { ViewBag.msg = "Input Error"; return(View()); } User currentUser = SetSession.GetCurrentUser(); user.Id = currentUser.Id; user.Email = currentUser.Email; UserManager userManager = new UserManager(); ViewBag.msg = userManager.UpdateUser(user); SetSession.SetUser(currentUser.Email); return(View()); }