private int userExists(string username) { LINQUserInformationDataContext ui = new LINQUserInformationDataContext(); var count = (from p in ui.LoginInformations where p.UserName == username select p).Count(); return count; }
public bool UserExists(string username) { LINQUserInformationDataContext ui = new LINQUserInformationDataContext(); var count = (from p in ui.LoginInformations where p.UserName == username select p).Count(); if (count > 0) return true; return false; }
public int login(string username, string password) { LINQUserInformationDataContext ui = new LINQUserInformationDataContext(); IQueryable<int> count = (from p in ui.LoginInformations where p.UserName == username && p.Password == password select p.ID); foreach (int element in count) { return element; } return -1; }
public bool CreateAccount(string username, string password) { if (userExists(username) != 0) return false; try { LINQUserInformationDataContext ui = new LINQUserInformationDataContext(); LoginInformation li = new LoginInformation(); { li.UserName = username; li.Password = password; }; ui.LoginInformations.InsertOnSubmit(li); ui.SubmitChanges(); } catch (Exception) { return false; } return true; }