public async Task <Result <League> > CreateLeague(LeagueCreationParameters parameters)
    {
        LeagueOptions options = new LeagueOptions(parameters.LeagueYearParameters);

        var validateOptions = options.Validate();

        if (validateOptions.IsFailure)
        {
            return(Result.Failure <League>(validateOptions.Error));
        }

        if (parameters.LeagueYearParameters.ScoringSystem.Name != DiminishingScoringSystem.StaticName)
        {
            return(Result.Failure <League>("That scoring mode is no longer supported."));
        }

        IEnumerable <int> years = new List <int>()
        {
            parameters.LeagueYearParameters.Year
        };
        League newLeague = new League(Guid.NewGuid(), parameters.LeagueName, parameters.Manager, years, parameters.PublicLeague, parameters.TestLeague, false, 0);
        await _fantasyCriticRepo.CreateLeague(newLeague, parameters.LeagueYearParameters.Year, options);

        return(Result.Success(newLeague));
    }
Example #2
0
        public async Task <Result <League> > CreateLeague(LeagueCreationParameters parameters)
        {
            LeagueOptions options = new LeagueOptions(parameters);

            var validateOptions = options.Validate();

            if (validateOptions.IsFailure)
            {
                return(Result.Failure <League>(validateOptions.Error));
            }

            IEnumerable <int> years = new List <int>()
            {
                parameters.InitialYear
            };
            League newLeague = new League(Guid.NewGuid(), parameters.LeagueName, parameters.Manager, years, parameters.PublicLeague, parameters.TestLeague, 0);
            await _fantasyCriticRepo.CreateLeague(newLeague, parameters.InitialYear, options);

            return(Result.Success(newLeague));
        }