public async Task <IActionResult> EditLeagueYearSettings([FromBody] LeagueYearSettingsViewModel request) { var currentUser = await _userManager.FindByNameAsync(User.Identity.Name); if (currentUser == null) { return(BadRequest()); } if (!request.ValidForOldYears()) { return(BadRequest()); } var systemWideSettings = await _interLeagueService.GetSystemWideSettings(); if (systemWideSettings.BidProcessingMode) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest()); } var league = await _fantasyCriticService.GetLeagueByID(request.LeagueID); if (league.HasNoValue) { return(BadRequest()); } var leagueYear = await _fantasyCriticService.GetLeagueYear(league.Value.LeagueID, request.Year); if (leagueYear.HasNoValue) { return(BadRequest()); } if (league.Value.LeagueManager.UserID != currentUser.UserID) { return(Forbid()); } EligibilityLevel eligibilityLevel = await _interLeagueService.GetEligibilityLevel(request.MaximumEligibilityLevel); EditLeagueYearParameters domainRequest = request.ToDomain(currentUser, eligibilityLevel); Result result = await _fantasyCriticService.EditLeague(league.Value, domainRequest); if (result.IsFailure) { return(BadRequest(result.Error)); } await _fantasyCriticService.UpdateFantasyPoints(leagueYear.Value); return(Ok()); }
public async Task <IActionResult> UpdateFantasyPoints([FromBody] UpdateFantasyPointsRequest request) { await _fantasyCriticService.UpdateFantasyPoints(request.Year); return(Ok()); }