Ejemplo n.º 1
0
        //ToDo: Move this class elsewhere.
        public static Friend GetFriendFromUser(user user)
        {
            var friend = new Friend { Alias = user.alias, EmailAddress = user.email };

            if (user.creation_time != null)
            {
                friend.CreationTime = (DateTime)user.creation_time;
            }

            if (user.skill_level != null)
            {
                friend.Level = (int)user.skill_level;
            }

            if (user.ranking != null)
            {
                friend.Ranking = (int)user.ranking;
            }

            if (user.experience != null)
            {
                friend.Experience = (long)user.experience;
            }

            return friend;
        }
Ejemplo n.º 2
0
        private void RemovePendingFriendRequests(user user)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                using (var db = new OzwegoDataClassesDataContext(connection))
                {
                    var frdReqQuery =
                        from frdReq in db.friendRequests
                        where (frdReq.from_user == user.ID || frdReq.to_user == user.ID)
                        select frdReq;

                    foreach (var frdReq in frdReqQuery)
                    {
                        db.friendRequests.DeleteOnSubmit(frdReq);
                    }

                    try
                    {
                        db.SubmitChanges();
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine(string.Format(
                                "Exception in Database.RemovePendingFriendRequests!\n Exception: {0} \n Callstack: {1}",
                                e.Message,
                                e.StackTrace));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public List<user_game> GetUserGameHistory(user user)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                using (var db = new OzwegoDataClassesDataContext(connection))
                {
                    var userQuery =
                        from g in db.user_games
                        where g.userID == user.ID
                        select g;

                    return userQuery.ToList();
                }
            }
        }
Ejemplo n.º 4
0
        public void AddNewUser(string newEmail, string newAlias)
        {
            if (string.IsNullOrEmpty(newEmail))
            {
                return;
            }

            if (string.IsNullOrEmpty(newAlias))
            {
                return;
            }

            using (var connection = new SqlConnection(ConnectionString))
            {
                using (var db = new OzwegoDataClassesDataContext(connection))
                {
                    var newUser = new user
                        {
                            email = newEmail,
                            alias = newAlias,
                            creation_time = DateTime.UtcNow,
                            last_seen_time = DateTime.UtcNow
                        };

                    db.users.InsertOnSubmit(newUser);

                    try
                    {
                        db.SubmitChanges();
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine(string.Format(
                                "Exception in Database.AddNewUser!\n Exception: {0} \n Callstack: {1}",
                                e.Message,
                                e.StackTrace));
                    }
                }
            }
        }
Ejemplo n.º 5
0
 partial void Deleteuser(user instance);
Ejemplo n.º 6
0
 partial void Updateuser(user instance);
Ejemplo n.º 7
0
 partial void Insertuser(user instance);
 partial void Deleteuser(user instance);
 partial void Updateuser(user instance);
 partial void Insertuser(user instance);