public bool Login(string login, string password) { var result = Entity.Users?.GetAll().Any(t => login == t.Login && password == t.Password); foreach (var t in Entity.Users.GetAll().Where(t => t.Login == login)) { _activeUser = t; } return (bool)result; }
public bool Register(string login, string password) { if (Entity.Users != null) { if (Entity.Users.GetAll().Any(t => t.Login == login)) { return false; } } Entity.Users?.Add(new User() { Login = login, Password = password }); foreach (var t in Entity.Users.GetAll().Where(t => t.Login == login)) { _activeUser = t; } Entity.SaveChanges(); return true; }
public void AddSubject(User user, Subject subject) { user.Subjects.Add(subject); Entity.SaveChanges(); }