Ejemplo n.º 1
0
        public IActionResult CreateMatch(SecretMatch secretMatch)
        {
            secretMatch.TheirSecretMatch = _createSecretMatch.FindRandomMatch(secretMatch.Name);

            var restrictions = _dataAccessor.GetMatchRestrictions(secretMatch.Name);

            while (restrictions.Any(r => r.RequestorName == secretMatch.Name && r.RestrictedName == secretMatch.TheirSecretMatch))
            {
                secretMatch.TheirSecretMatch = _createSecretMatch.FindRandomMatch(secretMatch.Name);
            }

            _dataAccessor.CreateMatch(secretMatch.Name, secretMatch.TheirSecretMatch, secretMatch.AllowReroll);

            return(View("GetMatch", secretMatch));
        }
Ejemplo n.º 2
0
        public IActionResult CreateMatch(UserPageModel secretMatch)
        {
            //verify access
            if (!verifySessionCookie())
            {
                return(View("InvalidCredentials"));
            }
            bool.TryParse(_dataAccessor.GetSettingValue("AllowMatching"), out bool allowMatch);
            secretMatch.AllowMatching = allowMatch;
            if (string.IsNullOrEmpty(secretMatch?.Name) || !secretMatch.AllowMatching)
            {
                //How? Why? Just start over
                return(RedirectToAction("SignIn"));
            }

            secretMatch.TheirSecretMatch = _createSecretMatch.FindRandomMatch(secretMatch.Name);
            _dataAccessor.CreateMatch(secretMatch.Name, secretMatch.TheirSecretMatch, secretMatch.AllowReroll);

            secretMatch = buildUserPageModelFromDB(secretMatch.Name);

            return(View("UserPage", secretMatch));
        }