Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var publisherService = new PublisherService();
            var solutionService  = new SolutionService();
            var entityService    = new EntityService();

            Console.WriteLine($"Default publisher: {publisherService.RetrieveTheDefaultPublisher().FriendlyName}");

            var solution = solutionService.RetrieveSolution("samplesolution");

            Console.WriteLine($"{solution.FriendlyName} - {solution.Id}");

            publisherService.CreatePublisher();
            solutionService.CreateSolution("samplesolution", "Sample Solution");

            solutionService.DeleteSolution("samplesolution");
            solutionService.CreateSolution("samplesolution", "Sample Solution");

            entityService.AddExistingEntity(new_order.EntityLogicalName, true, false);
            entityService.AddExistingEntity(new_order.EntityLogicalName, false, true);

            entityService.AddNewOptionSet();

            Console.WriteLine("Press to exit..");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void Create_ShouldCallInsertOnceWhenPublisher()
        {
            // Act
            _publisherService.CreatePublisher(_publisher);

            // Assert
            _publisherRepository.Verify(p => p.Insert(It.IsAny <Publisher>()));
        }
    public async Task <IActionResult> CreatePublisherForUser([FromBody] CreatePublisherForUserRequest request)
    {
        var leagueYearRecord = await GetExistingLeagueYear(request.LeagueID, request.Year, ActionProcessingModeBehavior.Allow, RequiredRelationship.LeagueManager, RequiredYearStatus.YearNotFinishedDraftNotStarted);

        if (leagueYearRecord.FailedResult is not null)
        {
            return(leagueYearRecord.FailedResult);
        }
        var validResult = leagueYearRecord.ValidResult !;
        var leagueYear  = validResult.LeagueYear;

        if (string.IsNullOrWhiteSpace(request.PublisherName))
        {
            return(BadRequest("You cannot have a blank name."));
        }

        var userToCreate = await _userManager.FindByIdAsync(request.UserID.ToString());

        if (userToCreate == null)
        {
            return(BadRequest());
        }

        bool userIsActive = await _leagueMemberService.UserIsActiveInLeagueYear(leagueYear.League, request.Year, userToCreate);

        if (!userIsActive)
        {
            return(BadRequest());
        }

        var publisherForUser = leagueYear.GetUserPublisher(userToCreate);

        if (publisherForUser is not null)
        {
            return(BadRequest("That player already has a publisher for this this league/year."));
        }

        await _publisherService.CreatePublisher(leagueYear, userToCreate, request.PublisherName);

        return(Ok());
    }