public static User Authorization(string _login, string _password) { WorkinhWithUserMethods m = new WorkinhWithUserMethods(); DbRepository <User> Users = new DbUsers(); List <User> users = Users.Items; User authorizeduser = new User(); var currentUser = users.SingleOrDefault(x => x.Login == _login); if (currentUser == null) { authorizeduser = null; } else { if (currentUser.Password == GetHash(_password)) { var s = GetHash(_password); authorizeduser = currentUser; } else { authorizeduser = null; } } return(authorizeduser); }
public static bool RegistrationNewUser(string _login, string _password, string _email) { DbUsers Users = new DbUsers(); if (!Users.Items.Exists(x => x.Login == _login)) { WorkinhWithUserMethods m = new WorkinhWithUserMethods(); List <User> users = Users.Items; Users.Add(new User { Login = _login, Password = GetHash(_password), Email = _email, FavouriteStations = new List <FavouriteStation>() }); return(true); } else { return(false); } }