示例#1
0
        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));
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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));
        }
示例#6
0
        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));
        }
示例#7
0
        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;
        }
示例#8
0
        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);
        }