Example #1
0
        ChatUser GetCurrentUserInstance(string login)
        {
            myChatDatabaseDataContext db = new myChatDatabaseDataContext();
            var user = from User in db.Users where User.username == login && User.deleted == false select User;

            User currentUser = user.First <User>();

            currentUser.userlastlogintime = DateTime.Now;
            db.SubmitChanges();

            return(new ChatUser(currentUser.user_id, currentUser.username));
        }
Example #2
0
        void CreateUser(string username, string password)
        {
            myChatDatabaseDataContext db = new myChatDatabaseDataContext();
            User newUser = new Database.User();

            newUser.username          = username;
            newUser.password          = password;
            newUser.usercreated       = DateTime.Now;
            newUser.userlastlogintime = DateTime.Now;
            newUser.deleted           = false;
            db.Users.InsertOnSubmit(newUser);
            db.SubmitChanges();
        }
Example #3
0
 bool UserDelete(bool userDataChecked, string username)
 {
     if (userDataChecked)
     {
         myChatDatabaseDataContext db = new myChatDatabaseDataContext();
         var  user        = from User in db.Users where User.username == username && User.deleted == false select User;
         User currentUser = user.First <User>();
         currentUser.deleted = true;
         db.SubmitChanges();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #4
0
 //ChatMessages
 bool SendMessageToDatabase(string message, int source, int reciver)
 {
     try
     {
         myChatDatabaseDataContext db = new myChatDatabaseDataContext();
         db_message currentMessage    = new db_message();
         currentMessage.message  = message;
         currentMessage.sender   = source;
         currentMessage.receiver = reciver;
         currentMessage.date     = DateTime.Now;
         db.db_messages.InsertOnSubmit(currentMessage);
         db.SubmitChanges();
         return(true);
     }
     catch { return(false); }
 }