public static bool AddNewSuggestion(string username, string text) { DatabaseDataContext db = new DatabaseDataContext(ConnectionString); SuggestionTable suggestion = new SuggestionTable() { Suggestion = text, Username = username }; db.SuggestionTables.InsertOnSubmit(suggestion); db.SubmitChanges(); return(db.SuggestionTables.Contains(suggestion)); }
public static bool AddNewSuggestion(string username, string text) { DatabaseDataContext db = new DatabaseDataContext(ConnectionString); SuggestionTable suggestion = new SuggestionTable() { Suggestion = text, Username = username }; db.SuggestionTables.InsertOnSubmit(suggestion); db.SubmitChanges(); return db.SuggestionTables.Contains(suggestion); }
public static bool UpdateRank(string username, int points, byte rank) { DatabaseDataContext db = new DatabaseDataContext(ConnectionString); User user = db.Users.FirstOrDefault(x => x.Username.ToLower() == username.ToLower()); if (user != null) { user.Points = points; user.Rank = rank; db.SubmitChanges(); return(true); } return(false); }
public static bool AddPrivateMessage(int fromId, int toId, string subject, string message) { PrivateMessageInfo pm = new PrivateMessageInfo() { FromID = fromId, ToID = toId, Subject = subject, TimeSent = DateTime.UtcNow, Message = message, TimeRead = DateTime.FromOADate(0) }; DatabaseDataContext db = new DatabaseDataContext(ConnectionString); db.PrivateMessageInfos.InsertOnSubmit(pm); db.SubmitChanges(); return db.PrivateMessageInfos.Contains(pm); }
public static bool AddPrivateMessage(int fromId, int toId, string subject, string message) { PrivateMessageInfo pm = new PrivateMessageInfo() { FromID = fromId, ToID = toId, Subject = subject, TimeSent = DateTime.UtcNow, Message = message, TimeRead = DateTime.FromOADate(0) }; DatabaseDataContext db = new DatabaseDataContext(ConnectionString); db.PrivateMessageInfos.InsertOnSubmit(pm); db.SubmitChanges(); return(db.PrivateMessageInfos.Contains(pm)); }
public static bool InsertUser(string username, string password, string email) { DatabaseDataContext db = new DatabaseDataContext(ConnectionString); bool exists = db.Users.Any(x => x.Username == username.ToLower() || x.Email == email.ToLower()); if (exists) { return(false); } User user = new User() { Id = 0, Username = username, Password = password.ToLower(), Email = email.ToLower(), }; db.Users.InsertOnSubmit(user); db.SubmitChanges(); return(db.Users.Contains(user)); }
public static bool UpdateRank(string username, int points, byte rank) { DatabaseDataContext db = new DatabaseDataContext(ConnectionString); User user = db.Users.FirstOrDefault(x => x.Username.ToLower() == username.ToLower()); if (user != null) { user.Points = points; user.Rank = rank; db.SubmitChanges(); return true; } return false; }
public static bool InsertUser(string username, string password, string email) { DatabaseDataContext db = new DatabaseDataContext(ConnectionString); bool exists = db.Users.Any(x => x.Username == username.ToLower() || x.Email == email.ToLower()); if (exists) return false; User user = new User() { Id = 0, Username = username, Password = password.ToLower(), Email = email.ToLower(), }; db.Users.InsertOnSubmit(user); db.SubmitChanges(); return db.Users.Contains(user); }