public bool InsertUser(RegisterModel model) { using (dbContext = new UserManagerEntities()) { User user; if (model.UserRole == UserType.SuperUser) { user = new SuperUser(); } else { user = new UsualUser(); } user.Email = model.Email; user.Login = model.Login; user.Password = model.Password; user.FirstName = model.FirstName; user.LastName = model.LastName; dbContext.Users.AddObject(user); dbContext.SaveChanges(); return true; } }
public User GetUserByName(string name) { using (dbContext = new UserManagerEntities()) { return dbContext.Users.FirstOrDefault(x => x.Login == name); } }
/// <summary> /// Checks if user with the specified data already exists /// </summary> /// <param name="loginData"></param> /// <returns></returns> public static bool CheckUser(LoginModel loginData) { dbContext = new UserManagerEntities(); var users = from u in dbContext.Users where u.Login.Equals(loginData.Login) && u.Password.Equals(loginData.Password) select u; if (users.Count() == 1) { return true; } return false; }
private DataProvider() { DB = new UserManagerEntities(); }