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()); }
public int Create(CreatePublisherRequest request) { var publisherEntity = new PublisherEntity() { LicenceNumber = request.LicenceNumber, Name = request.Name }; publisherRepository.Create(publisherEntity); return(publisherEntity.Id); }
protected void RestartRemotePublisher() { logger.Debug("Restarting remote publisher"); CreatePublisherRequest request = new CreatePublisherRequest(); request.iteration = Iteration; request.isControlIteration = IsControlIteration; request.Cls = Class; request.args = Args; Send("CreatePublisher", JsonConvert.SerializeObject(request)); }