public async Task <IActionResult> MakePickupBid([FromBody] PickupBidRequest request) { if (!ModelState.IsValid) { return(BadRequest()); } var publisher = await _fantasyCriticService.GetPublisher(request.PublisherID); if (publisher.HasNoValue) { return(BadRequest()); } Maybe <LeagueYear> leagueYear = await _fantasyCriticService.GetLeagueYear(publisher.Value.League.LeagueID, publisher.Value.Year); if (leagueYear.HasNoValue) { return(BadRequest()); } if (!leagueYear.Value.PlayStatus.PlayStarted) { return(BadRequest("Play has not started for that year.")); } var currentUser = await _userManager.FindByNameAsync(User.Identity.Name); bool userIsInLeague = await _fantasyCriticService.UserIsInLeague(publisher.Value.League, currentUser); bool userIsPublisher = (currentUser.UserID == publisher.Value.User.UserID); if (!userIsInLeague || !userIsPublisher) { return(Forbid()); } var masterGame = await _fantasyCriticService.GetMasterGame(request.MasterGameID); if (masterGame.HasNoValue) { return(BadRequest("That master game does not exist.")); } ClaimResult bidResult = await _fantasyCriticService.MakePickupBid(publisher.Value, masterGame.Value, request.BidAmount); var viewModel = new PickupBidResultViewModel(bidResult); return(Ok(viewModel)); }