Exemplo n.º 1
0
        public async Task<ActionResult> Execute(string inep, CreateGroupRequest createGroupRequest)
        {
            if (createGroupRequest.Inep != inep)
                return BadRequest();

            await _createGroupUseCase.Execute(createGroupRequest);

            return NoContent();
        }
        public async Task <IActionResult> CreateGroup(
            [FromServices] ICreateGroupUseCase createGroupUseCase,
            [FromServices] CreateGroupPresenter createGroupPresenter,
            [FromBody] CreateGroupRequest input)
        {
            await createGroupUseCase.Execute(new CreateGroupInput(input.Title, input.Curator, input.HeadMan));

            return(createGroupPresenter.ViewModel);
        }
        public async Task Should_CreateGroupUseCase(string name, string inep, string namePublicSchool, string zipCode, string baseAddress, string complementAddress, string neighborhood, string city, Domain.Shared.ValueObjects.Addresses.State state)
        {
            CreatePublicSchoolRequest createPublicSchoolRequest = new CreatePublicSchoolRequest()
            {
                Inep    = inep,
                Name    = namePublicSchool,
                Address = new AddressDto()
                {
                    ZipCode           = zipCode,
                    BaseAddress       = baseAddress,
                    ComplementAddress = complementAddress,
                    Neighborhood      = neighborhood,
                    City  = city,
                    State = state
                }
            };

            await _createPublicSchoolUseCase.Execute(createPublicSchoolRequest);

            CreateGroupRequest createGroupRequest = new CreateGroupRequest()
            {
                Inep = inep,
                Name = name
            };

            await _createGroupUseCase.Execute(createGroupRequest);

            var groups = await _getGroupsUseCase.Execute(inep);

            groups.Should().NotBeNull();
            groups.Should().OnlyHaveUniqueItems();

            foreach (var g in groups)
            {
                var existentGroup = await _getGroupUseCaso.Execute(g.Id);

                existentGroup.Should().NotBeNull();
                existentGroup.Should().BeEquivalentTo(g);
            }
        }