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;
 }
Beispiel #3
0
 public int CheckLogin(UserData lm)
 {
     var userid = db.Users.AsNoTracking().Where(x => x.name == lm.UserName && x.password == lm.Password).Select(s => s.id).FirstOrDefault();
     return userid;
 }
 /// <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;
 }