public async Task <IActionResult> CreatePublisher([FromBody] CreatePublisherRequest request) { var league = await _fantasyCriticService.GetLeagueByID(request.LeagueID); if (league.HasNoValue) { return(BadRequest()); } var currentUser = await _userManager.FindByNameAsync(User.Identity.Name); bool userIsInLeague = await _fantasyCriticService.UserIsInLeague(league.Value, currentUser); if (!userIsInLeague) { return(Forbid()); } var currentPublishers = await _fantasyCriticService.GetPublishersInLeagueForYear(league.Value, request.Year); var publisherForUser = currentPublishers.SingleOrDefault(x => x.User.UserID == currentUser.UserID); if (publisherForUser != null) { return(BadRequest("You have already created a publisher for this this league/year.")); } await _fantasyCriticService.CreatePublisher(league.Value, request.Year, currentUser, request.PublisherName, currentPublishers); return(Ok()); }