public static Models.User GetUser(string username) { var userDb = (from x in DbConnector.GetConnection().Users where x.UserName == username select x).Single(); Models.User userModel = new User { Email= userDb.EMail, Password = userDb.Password, Username = userDb.UserName, Id = userDb.Id}; return userModel; }
public ActionResult Register(MvcApplication4.Models.User u) { if (ModelState.IsValid) { using (UserEntities dc = new UserEntities()) { Session["LogedUserID"] = u.id.ToString(); Session["LogedUsername"] = u.userName.ToString(); u.password = HashPassword(u.password); Session["LogedPassword"] = u.password.ToString(); dc.Users.Add(u); dc.SaveChanges(); ModelState.Clear(); u = null; return RedirectToAction("AfterLogin"); } } return View(u); }