public static bool IsUserByPaswordFound(UserModel user) { using (var conn = ConnectionFactory()) { var adapter = new BeautifulMusicDataSetTableAdapters.UserTableAdapter { Connection = conn }; var id = adapter.GetUserByPassword(user.Login, user.Password); if (id != null) { user.Id = (int)id; } return(user.Id > 0); } }
public static UserModel AddUser(UserModel user) { using (var conn = ConnectionFactory()) { var adapter = new BeautifulMusicDataSetTableAdapters.UserTableAdapter { Connection = conn }; var found = (int)adapter.CheckByLogin(user.Login); if (found > 0) { throw new DuplicateWaitObjectException("Пользователь с таким именем уже существует"); } var row = MusicDataSet.User.NewUserRow(); row.Login = user.Login; row.Password = user.Password; MusicDataSet.User.AddUserRow(row); adapter.Update(row); user.Id = row.Id; return(user); } }