Esempio n. 1
0
        public void BroadcastPointsReceived(string username, string tableName, int numberOfPoints)
        {
            var clients  = GetConnectedUsersForTable(tableName);
            var context  = GlobalHost.ConnectionManager.GetHubContext <TriviaHub>();
            var response = new UserWithPoints {
                Username = username, Points = numberOfPoints
            };

            context.Clients.Clients(clients).PointsReceived(response);
        }
Esempio n. 2
0
        public void BroadcastUserConnected(string username, string tableName)
        {
            var userPoints = userManager.GetUserPointsSync(username);
            var res        = new UserWithPoints {
                Username = username, Points = userPoints
            };
            var clients = GetConnectedUsersWithoutSpecificOne(username, tableName);
            var context = GlobalHost.ConnectionManager.GetHubContext <TriviaHub>();

            context.Clients.Clients(clients).NewUserConnected(res);
        }
Esempio n. 3
0
        public List <UserWithPoints> GetHousingQualifiers(Guid EstateID, Guid UserID, string Token)
        {
            if (!this.UserHandler.AuthenticateUser(UserID, Token))
            {
                throw new Exception("Unauthorized");
            }

            var estate = this.Context.Estates.Where(x => x.ID == EstateID).FirstOrDefault();

            if (estate.UserID != UserID)
            {
                throw new Exception("Unauthorized");
            }

            var waitingListItems = this.Context.WaitingList.Where(x => x.EstateID == EstateID).ToList();
            var ruleset          = this.Context.Rulesets.Where(x => x.ID == estate.RulesetID).FirstOrDefault();

            List <UserWithPoints> response = new List <UserWithPoints>();

            foreach (var item in waitingListItems)
            {
                UserWithPoints user = new UserWithPoints();
                user.EstateID = estate.ID;
                var             UserEntity  = this.Context.Users.Where(x => x.ID == item.UserID).FirstOrDefault();
                UserDetailModel userDetails = this.Context.UserDetails.Where(x => x.UserID == item.UserID).FirstOrDefault();
                if (userDetails == null)
                {
                    user.Points = 0;
                    user.About  = "Brugeren har ikke skrevet om sig selv";
                }
                else
                {
                    if (ruleset.Dog == userDetails.Dog)
                    {
                        user.Points++;
                    }
                    if (ruleset.Cat == userDetails.Cat)
                    {
                        user.Points++;
                    }
                    if (ruleset.Fish == userDetails.Fish)
                    {
                        user.Points++;
                    }
                    if (ruleset.Creep == userDetails.Creep)
                    {
                        user.Points++;
                    }
                    user.About = userDetails.About;
                }

                user.ID        = item.UserID;
                user.FirstName = UserEntity.FirstName;
                user.LastName  = UserEntity.LastName;
                user.Email     = UserEntity.Email;
                user.Phone     = UserEntity.Phone;
                user.Type      = UserEntity.Type;

                response.Add(user);
            }
            response.OrderBy(usr => usr.Points);
            return(response);
        }