Пример #1
0
    public static string GetSessionToken(string Email)
    {
        try
        {
            LinqGameDataContext dc = new LinqGameDataContext();
            Guid token             = Guid.NewGuid();

            List <UserSession> usList = (from t in dc.UserSessions
                                         where t.UserID == GetUser(Email).UserID
                                         select t).ToList <UserSession>();

            dc.UserSessions.DeleteAllOnSubmit <UserSession>(usList);

            UserSession us = new UserSession();
            us.UserID       = GetUser(Email).UserID;
            us.ExpiresOn    = DateTime.Now.AddHours(1);
            us.SessionToken = token.ToString();

            dc.UserSessions.InsertOnSubmit(us);
            dc.SubmitChanges();

            return(token.ToString());
        }
        catch
        {
            return(string.Empty);
        }
    }
Пример #2
0
    public static bool InsertWord(string Word)
    {
        try
        {
            LinqGameDataContext dc = new LinqGameDataContext();

            LinqWord word = new LinqWord();
            word.Word      = Word;
            word.IsRemoved = false;

            dc.LinqWords.InsertOnSubmit(word);
            dc.SubmitChanges();

            return(true);
        }
        catch
        {
            return(false);
        }
    }
Пример #3
0
    public static bool CheckSessionToken(string token)
    {
        try
        {
            LinqGameDataContext dc = new LinqGameDataContext();

            UserSession us = (from t in dc.UserSessions
                              where t.SessionToken == token &&
                              t.ExpiresOn > DateTime.Now
                              select t).First <UserSession>();

            us.ExpiresOn = DateTime.Now.AddHours(1);

            dc.SubmitChanges();

            return(true);
        }
        catch
        {
            return(false);
        }
    }
Пример #4
0
    public static bool CheckSessionToken(string token)
    {
        try
        {
            LinqGameDataContext dc = new LinqGameDataContext();

            UserSession us = (from t in dc.UserSessions
                              where t.SessionToken == token &&
                                t.ExpiresOn > DateTime.Now
                              select t).First<UserSession>();

            us.ExpiresOn = DateTime.Now.AddHours(1);

            dc.SubmitChanges();

            return true;
        }
        catch
        {
            return false;
        }
    }
Пример #5
0
    public static bool PostChat(string email, string message)
    {
        try
        {
            LinqGameDataContext dc = new LinqGameDataContext();

            LinqGameChat lgc = new LinqGameChat();
            lgc.IsExCathedra = false;
            lgc.PostedAt     = DateTime.Now;
            lgc.GameID       = 1; // Lobby - for testing
            lgc.UserID       = GetUser(email).UserID;
            lgc.ChatText     = message;

            dc.LinqGameChats.InsertOnSubmit(lgc);
            dc.SubmitChanges();

            return(true);
        }
        catch
        {
            return(false);
        }
    }
Пример #6
0
    public static bool CreateUser(string Email, string Nickname, string Password)
    {
        try
        {
            LinqGameDataContext dc = new LinqGameDataContext();

            User u = new User();
            u.Email             = Email;
            u.Nickname          = Nickname;
            u.VerificationToken = GetVerificationHash(Email, Password);

            u.IsAdmin  = false;
            u.JoinDate = DateTime.Now;

            dc.Users.InsertOnSubmit(u);
            dc.SubmitChanges();

            return(true);
        }
        catch
        {
            return(false);
        }
    }
Пример #7
0
    public static bool CreateUser(string Email, string Nickname, string Password)
    {
        try
        {
            LinqGameDataContext dc = new LinqGameDataContext();

            User u = new User();
            u.Email = Email;
            u.Nickname = Nickname;
            u.VerificationToken = GetVerificationHash(Email, Password);

            u.IsAdmin = false;
            u.JoinDate = DateTime.Now;

            dc.Users.InsertOnSubmit(u);
            dc.SubmitChanges();

            return true;
        }
        catch
        {
            return false;
        }
    }
Пример #8
0
    public static bool PostChat(string email, string message)
    {
        try
        {
            LinqGameDataContext dc = new LinqGameDataContext();

            LinqGameChat lgc = new LinqGameChat();
            lgc.IsExCathedra = false;
            lgc.PostedAt = DateTime.Now;
            lgc.GameID = 1; // Lobby - for testing
            lgc.UserID = GetUser(email).UserID;
            lgc.ChatText = message;

            dc.LinqGameChats.InsertOnSubmit(lgc);
            dc.SubmitChanges();

            return true;
        }
        catch
        {
            return false;
        }
    }
Пример #9
0
    public static bool InsertWord(string Word)
    {
        try
        {
            LinqGameDataContext dc = new LinqGameDataContext();

            LinqWord word = new LinqWord();
            word.Word = Word;
            word.IsRemoved = false;

            dc.LinqWords.InsertOnSubmit(word);
            dc.SubmitChanges();

            return true;
        }
        catch
        {
            return false;
        }
    }
Пример #10
0
    public static string GetSessionToken(string Email)
    {
        try
        {
            LinqGameDataContext dc = new LinqGameDataContext();
            Guid token = Guid.NewGuid();

            List<UserSession> usList = (from t in dc.UserSessions
                                        where t.UserID == GetUser(Email).UserID
                                        select t).ToList<UserSession>();

            dc.UserSessions.DeleteAllOnSubmit<UserSession>(usList);

            UserSession us = new UserSession();
            us.UserID = GetUser(Email).UserID;
            us.ExpiresOn = DateTime.Now.AddHours(1);
            us.SessionToken = token.ToString();

            dc.UserSessions.InsertOnSubmit(us);
            dc.SubmitChanges();

            return token.ToString();
        }
        catch
        {
            return string.Empty;
        }
    }