Exemple #1
0
        /// <summary>
        /// Get the response if the group has reached the max fb on this week
        /// </summary>
        /// <returns>A error message</returns>
        private LaunchFootballBetManager getMaxReachResponse()
        {
            LaunchFootballBetManager res = new LaunchFootballBetManager();

            res.typeBets           = new List <NameWinRate>();
            res.typePays           = new List <NameWinRate>();
            res.competitionMatches = new List <AvailableBet>();
            res.competitionMatches.Add(new AvailableBet
            {
                matches     = new List <FootballMatch>(),
                competition = "MaximunWeekBetsReached"
            });

            return(res);
        }
Exemple #2
0
        /// <summary>
        /// Get the info to launch a new fb
        /// </summary>
        /// <param name="groupName">The name of the group where the new bet wants to be launched</param>
        /// <returns>IActionResult of the get fb page action</returns>
        /// See <see cref="Areas.GroupManage.Models.LaunchFootballBetManager"/> to know the response structure
        public IActionResult getFootBallPage([Required] string groupName)
        {
            User caller = TokenUserManager.getUserFromToken(HttpContext, _context);

            if (!caller.open)
            {
                return(BadRequest(new { error = "YoureBanned" }));
            }
            if (AdminPolicy.isAdmin(caller, _context))
            {
                return(BadRequest("notAllowed"));
            }
            Group group = new Group();

            if (!GroupMakerFuncionlities.checkFuncionality(caller, ref group, groupName, GroupMakerFuncionality.STARTCREATE_FOOTBALL_BET, _context))
            {
                return(BadRequest());
            }
            if (!checkMaxBetAllowed(group))
            {
                return(Ok(getMaxReachResponse()));
            }

            try
            {
                List <FootballMatch>     availableMatches = getAvailableMatchDays(group);
                LaunchFootballBetManager response         = new LaunchFootballBetManager();
                response.typeBets           = loadTypeFootballBet();
                response.typePays           = loadTypePays();
                response.competitionMatches = getAvailableBets(availableMatches);

                return(Ok(response));
            }
            catch (Exception)
            {
                return(StatusCode(500));
            }
        }