public void RegisterUser(UserModel user) { databaseforassignmentEntities1 context = new databaseforassignmentEntities1(); User DBuser = new User(); if (context.Users.SingleOrDefault(u => u.email == user.email) == null) { DBuser.accountnumber = user.accountnumber; DBuser.balance = 0; DBuser.city = user.city; DBuser.email = user.email; DBuser.name = user.name; DBuser.password = user.password; DBuser.status = "active"; context.Users.Add(DBuser); context.SaveChanges(); } }
public UserModel GetUserByLogin(string email, string password) { databaseforassignmentEntities1 context = new databaseforassignmentEntities1(); var query = from user in context.Users where user.email == email && user.password.ToString() == password && user.status == "active" select user; UserModel loginUser = new UserModel(); foreach (var u in query) { loginUser.accountnumber = u.accountnumber; loginUser.balance = u.balance; loginUser.city = u.city; loginUser.email = u.email; loginUser.name = u.name; loginUser.password = u.password; } return loginUser; }