Beispiel #1
0
        /// <summary>
        /// Get all users for the calendarID (corresponds to player group) for which Player==true
        /// </summary>
        internal static List<User> Players(int calendarID)
        {
            List<User> players = new List<User>();

             DnDSignUpEntities entities = new DnDSignUpEntities();

             //IEnumerable<RegisteredUser> users = entities.RegisteredUsers.Where(u => u.Player == true);

             DbSet<RegisteredUser> regUsers = entities.RegisteredUsers;
             DbSet<PlayerGroup> groups = entities.PlayerGroups;

             var dbUsers =
                from dbUser in regUsers
                join aGroup in groups
                on dbUser.FacebookID equals aGroup.RegisteredUser
                where dbUser.Player == true
                && aGroup.GroupID == calendarID
                select new
                {
                    FacebookID = dbUser.FacebookID,
                    SpouseOf = dbUser.SpouseOf
                };

             foreach (var dbUser in dbUsers)
             {
                 User user = new User();
                 user.Spouse = new Spouse();
                 user.FBID = dbUser.FacebookID;
                 user.FbInfo = GetFacebookInfo(dbUser.FacebookID);
                 user.IsPlayer = true;
                 if (user.FbInfo != null)
                     user.Name = user.FbInfo.First;//MLW TODO check for null
                 user.Spouse.fbInfo = GetFacebookInfo(dbUser.SpouseOf);
                 user.Spouse.FBID = dbUser.SpouseOf == null ? User.FBID_Def : (long)dbUser.SpouseOf;

                 players.Add(user);
             }

             return players;
        }
Beispiel #2
0
        internal static User GetUser(long facebookID)
        {
            DnDSignUpEntities entities = new DnDSignUpEntities();

            RegisteredUser regUser = entities.RegisteredUsers.SingleOrDefault(x => x.FacebookID == facebookID);

            if (regUser == null) return null;

            User user = new User();
            user.Spouse = new Spouse();
            user.FBID = regUser.FacebookID;
            user.IsPlayer = regUser.Player;
            user.FbInfo = GetFacebookInfo(regUser.FacebookID);
            if (user.FbInfo != null)
                user.Name = user.FbInfo.First;  //MLW TODO check for null
            user.Spouse.fbInfo = GetFacebookInfo(regUser.SpouseOf);
            user.Spouse.FBID = regUser.SpouseOf == null ? User.FBID_Def : (long)regUser.SpouseOf;

            return user;
        }