public ActionResult Match(int white, int black, int minutes, int gain, string identifier)
        {
            if (!MatchIdentifier.CheckMatchIdentifier(white, black, minutes, gain, identifier))
            {
                return(HttpNotFound());
            }

            var match = new Match
            {
                White   = userRepository.FindUserById(white),
                Black   = userRepository.FindUserById(black),
                IsRated = true
            };

            ViewBag.Seconds    = minutes * 60;
            ViewBag.Gain       = gain;
            ViewBag.IsWhite    = DateTime.Now.Ticks % 2 == 0;
            ViewBag.Identifier = identifier;
            return(View(match));
        }
        public ActionResult ListOnlineUsers()
        {
            var currentUser   = userRepository.FindUserById(WebSecurity.CurrentUserId);
            var listUsers     = new List <IndexViewModel>();
            var loggedInUsers = SparringHub.GetOnlineUsers();

            if (loggedInUsers != null && loggedInUsers.Count > 0)
            {
                //List<string> loggedInUsers = (List<string>)HttpRuntime.Cache["LoggedInUsers"];
                foreach (var user in loggedInUsers)
                {
                    //var loggedUser = userRepository.FindUserByUserName(user);
                    if (user.PlayingRating >= currentUser.RatingFrom && user.PlayingRating <= currentUser.RatingTo && user.ID != currentUser.ID)
                    {
                        listUsers.Add(new IndexViewModel
                        {
                            User       = user,
                            Identifier = MatchIdentifier.CalculateMatchIdentifier(currentUser.ID, user.ID, currentUser.Minutes, currentUser.Gain)
                        });
                    }
                }
            }
            return(PartialView(listUsers));
        }
        public void Spare(int whiteId, int blackId, int minutes, int gain)
        {
            var player = users.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId);

            if (player == null)
            {
                return;
            }
            var opponent = users.FirstOrDefault(x => x.Name.Equals(blackId.ToString()));

            if (opponent == null)
            {
                return;
            }
            Clients.Client(opponent.ConnectionId).sparePartners(whiteId, blackId, minutes, gain, MatchIdentifier.CalculateMatchIdentifier(whiteId, blackId, minutes, gain));
        }