public ActionResult Login(LoginModel lm) { UserData ud = new UserData(); ud = convert.UserModelToData(lm); var userId = ud.CheckLogin(ud); if (userId > 0) { FormsAuthentication.SetAuthCookie(userId.ToString(), false); return RedirectToAction("Stories"); } else { return RedirectToAction("LoginPage"); } }
/// <summary> /// UserData convert to LoginModel /// </summary> /// <param name="um"></param> /// <returns></returns> public UserData UserModelToData(LoginModel um) { UserData ud = new UserData() { Password = um.Password, UserName = um.Login }; return ud; }
/// <summary> /// UserData convert to LoginModel /// </summary> /// <param name="ud"></param> /// <returns></returns> public LoginModel UserDataToModel(UserData ud) { LoginModel um = new LoginModel() { Password = ud.Password, Login = ud.UserName }; return um; }