public LeagueCreationParameters ToDomain(FantasyCriticUser manager, EligibilityLevel maximumEligibilityLevel) { DraftSystem draftSystem = Lib.Enums.DraftSystem.FromValue(DraftSystem); PickupSystem pickupSystem = Lib.Enums.PickupSystem.FromValue(PickupSystem); ScoringSystem scoringSystem = Lib.Domain.ScoringSystems.ScoringSystem.GetScoringSystem(ScoringSystem); int freeDroppableGames = FreeDroppableGames; if (UnlimitedFreeDroppableGames) { freeDroppableGames = -1; } int willNotReleaseDroppableGames = WillNotReleaseDroppableGames; if (UnlimitedWillNotReleaseDroppableGames) { willNotReleaseDroppableGames = -1; } int willReleaseDroppableGames = WillReleaseDroppableGames; if (UnlimitedWillReleaseDroppableGames) { willReleaseDroppableGames = -1; } LeagueCreationParameters parameters = new LeagueCreationParameters(manager, LeagueName, StandardGames, GamesToDraft, CounterPicks, freeDroppableGames, willNotReleaseDroppableGames, willReleaseDroppableGames, DropOnlyDraftGames, InitialYear, maximumEligibilityLevel, AllowYearlyInstallments, AllowEarlyAccess, AllowFreeToPlay, AllowReleasedInternationally, AllowExpansions, AllowUnannouncedGames, draftSystem, pickupSystem, scoringSystem, PublicLeague, TestLeague); return(parameters); }
public LeagueCreationParameters ToDomain(FantasyCriticUser manager, IReadOnlyDictionary <string, MasterGameTag> tagDictionary) { DraftSystem draftSystem = Lib.Enums.DraftSystem.FromValue(DraftSystem); PickupSystem pickupSystem = Lib.Enums.PickupSystem.FromValue(PickupSystem); ScoringSystem scoringSystem = Lib.Domain.ScoringSystems.ScoringSystem.GetScoringSystem(ScoringSystem); int freeDroppableGames = FreeDroppableGames; if (UnlimitedFreeDroppableGames) { freeDroppableGames = -1; } int willNotReleaseDroppableGames = WillNotReleaseDroppableGames; if (UnlimitedWillNotReleaseDroppableGames) { willNotReleaseDroppableGames = -1; } int willReleaseDroppableGames = WillReleaseDroppableGames; if (UnlimitedWillReleaseDroppableGames) { willReleaseDroppableGames = -1; } var leagueTags = Tags.ToDomain(tagDictionary); LeagueCreationParameters parameters = new LeagueCreationParameters(manager, LeagueName, StandardGames, GamesToDraft, CounterPicks, freeDroppableGames, willNotReleaseDroppableGames, willReleaseDroppableGames, DropOnlyDraftGames, CounterPicksBlockDrops, MinimumBidAmount, InitialYear, leagueTags, draftSystem, pickupSystem, scoringSystem, PublicLeague, TestLeague); return(parameters); }
public LeagueCreationParameters ToDomain(FantasyCriticUser manager, IReadOnlyDictionary <string, MasterGameTag> tagDictionary) { LeagueYearParameters leagueYearParameters = LeagueYearSettings.ToDomain(tagDictionary); LeagueCreationParameters parameters = new LeagueCreationParameters(manager, LeagueName, PublicLeague, TestLeague, leagueYearParameters); return(parameters); }
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)); }
public LeagueCreationParameters ToDomain(FantasyCriticUser manager, EligibilityLevel maximumEligibilityLevel) { DraftSystem draftSystem = Lib.Enums.DraftSystem.FromValue(DraftSystem); PickupSystem pickupSystem = Lib.Enums.PickupSystem.FromValue(PickupSystem); ScoringSystem scoringSystem = Lib.Domain.ScoringSystems.ScoringSystem.GetScoringSystem(ScoringSystem); LeagueCreationParameters parameters = new LeagueCreationParameters(manager, LeagueName, StandardGames, GamesToDraft, CounterPicks, InitialYear, maximumEligibilityLevel, AllowYearlyInstallments, AllowEarlyAccess, draftSystem, pickupSystem, scoringSystem); return(parameters); }
public LeagueOptions(LeagueCreationParameters parameters) { StandardGames = parameters.StandardGames; GamesToDraft = parameters.GamesToDraft; CounterPicks = parameters.CounterPicks; MaximumEligibilityLevel = parameters.MaximumEligibilityLevel; AllowYearlyInstallments = parameters.AllowYearlyInstallments; AllowEarlyAccess = parameters.AllowEarlyAccess; DraftSystem = parameters.DraftSystem; PickupSystem = parameters.PickupSystem; ScoringSystem = parameters.ScoringSystem; }
public async Task <IActionResult> CreateLeague([FromBody] CreateLeagueRequest request) { var currentUser = await _userManager.FindByNameAsync(User.Identity.Name); if (currentUser == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest()); } if (!request.ValidForOldYears()) { return(BadRequest()); } var supportedYears = await _interLeagueService.GetSupportedYears(); var selectedSupportedYear = supportedYears.SingleOrDefault(x => x.Year == request.InitialYear); if (selectedSupportedYear is null) { return(BadRequest()); } var userIsBetaUser = await _userManager.IsInRoleAsync(currentUser, "BetaTester"); bool yearIsOpen = selectedSupportedYear.OpenForCreation || (userIsBetaUser && selectedSupportedYear.OpenForBetaUsers); if (!yearIsOpen) { return(BadRequest()); } EligibilityLevel eligibilityLevel = await _interLeagueService.GetEligibilityLevel(request.MaximumEligibilityLevel); LeagueCreationParameters domainRequest = request.ToDomain(currentUser, eligibilityLevel); var league = await _fantasyCriticService.CreateLeague(domainRequest); if (league.IsFailure) { return(BadRequest(league.Error)); } return(Ok()); }
public LeagueOptions(LeagueCreationParameters parameters) { StandardGames = parameters.StandardGames; GamesToDraft = parameters.GamesToDraft; CounterPicks = parameters.CounterPicks; FreeDroppableGames = parameters.FreeDroppableGames; WillNotReleaseDroppableGames = parameters.WillNotReleaseDroppableGames; WillReleaseDroppableGames = parameters.WillReleaseDroppableGames; DropOnlyDraftGames = parameters.DropOnlyDraftGames; AllowedEligibilitySettings = parameters.AllowedEligibilitySettings; DraftSystem = parameters.DraftSystem; PickupSystem = parameters.PickupSystem; ScoringSystem = parameters.ScoringSystem; PublicLeague = parameters.PublicLeague; }
public async Task <IActionResult> CreateLeague([FromBody] CreateLeagueRequest request) { var currentUserResult = await GetCurrentUser(); if (currentUserResult.IsFailure) { return(BadRequest(currentUserResult.Error)); } var currentUser = currentUserResult.Value; var requestValid = request.IsValid(); if (requestValid.IsFailure) { return(BadRequest(requestValid.Error)); } var supportedYears = await _interLeagueService.GetSupportedYears(); var selectedSupportedYear = supportedYears.SingleOrDefault(x => x.Year == request.LeagueYearSettings.Year); if (selectedSupportedYear is null) { return(BadRequest("That year is not supported.")); } var userIsBetaUser = await _userManager.IsInRoleAsync(currentUser, "BetaTester"); bool yearIsOpen = selectedSupportedYear.OpenForCreation || (userIsBetaUser && selectedSupportedYear.OpenForBetaUsers); if (!yearIsOpen) { return(BadRequest("That year is not open for play.")); } var tagDictionary = await _interLeagueService.GetMasterGameTagDictionary(); LeagueCreationParameters domainRequest = request.ToDomain(currentUser, tagDictionary); var league = await _fantasyCriticService.CreateLeague(domainRequest); if (league.IsFailure) { return(BadRequest(league.Error)); } return(Ok()); }
public LeagueOptions(LeagueCreationParameters parameters) { StandardGames = parameters.StandardGames; GamesToDraft = parameters.GamesToDraft; CounterPicks = parameters.CounterPicks; FreeDroppableGames = parameters.FreeDroppableGames; WillNotReleaseDroppableGames = parameters.WillNotReleaseDroppableGames; WillReleaseDroppableGames = parameters.WillReleaseDroppableGames; DropOnlyDraftGames = parameters.DropOnlyDraftGames; CounterPicksBlockDrops = parameters.CounterPicksBlockDrops; MinimumBidAmount = parameters.MinimumBidAmount; LeagueTags = parameters.LeagueTags; DraftSystem = parameters.DraftSystem; PickupSystem = parameters.PickupSystem; ScoringSystem = parameters.ScoringSystem; PublicLeague = parameters.PublicLeague; }
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)); }
public async Task <IActionResult> CreateLeague([FromBody] CreateLeagueRequest request) { var currentUser = await _userManager.FindByNameAsync(User.Identity.Name); if (currentUser == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest()); } EligibilityLevel eligibilityLevel = await _fantasyCriticService.GetEligibilityLevel(request.MaximumEligibilityLevel); LeagueCreationParameters domainRequest = request.ToDomain(currentUser, eligibilityLevel); await _fantasyCriticService.CreateLeague(domainRequest); return(Ok()); }