Exemplo n.º 1
0
        public IActionResult Delete([FromBody] GroupCoords coords)
        {
            return(DbTransaction((c, t) => {
                if (!IsOrganizationAdmin())
                {
                    throw new UnauthorizedAccessException();
                }

                CalendarStorer.DeleteGroupRounds(c, t, coords);
                return true;
            }));
        }
        public IActionResult DeleteGroupCalendar(long idGroup)
        {
            return(DbTransaction((c, t) =>
            {
                if (!IsOrganizationAdmin())
                {
                    throw new UnauthorizedAccessException();
                }

                CalendarStorer.DeleteCalendar(c, t, idGroup);

                return true;
            }));
        }
Exemplo n.º 3
0
        public IActionResult GenerateTournamentCalendar([FromBody] CalendarGenInput input)
        {
            return(DbOperation(c => {
                if (input == null)
                {
                    throw new NoDataException();
                }
                if (!IsOrganizationAdmin())
                {
                    throw new UnauthorizedAccessException();
                }

                CalendarResult result = null;

                var teams = GetTeams(c, null, input.TeamIds);

                switch ((CalendarType)input.Type)
                {
                case CalendarType.League:
                    result = LeaguePlanner.Calculate(input, null, GetUserLocale(), teamIds => GetTeamPreferences(c, null, teamIds), idTeam => GetTeamName(teams, idTeam));
                    break;

                case CalendarType.Knockout:
                    result = KnockoutPlanner.Calculate(input, null, GetUserLocale(), teamIds => GetTeamPreferences(c, null, teamIds), c);
                    break;

                default:
                    break;
                }

                if (!input.IsPreview)
                {
                    CalendarStorer.SaveRounds(c, input.Group, result);
                }

                return result;
            }));
        }