예제 #1
0
        public async Task <IActionResult> PostAsync([FromBody][Required] RegisterFarmRequest request)
        {
            var input = new FarmRegisterInput(request.Name,
                                              new PositiveDecimal(request.Area),
                                              new InscricaoEstadual(request.InscricaoEstadualState, request.InscricaoEstadualNumber));

            await _useCase.ExecuteAsync(input);

            return(_presenter.ViewModel);
        }
예제 #2
0
        public async Task ExecuteAsync(FarmRegisterInput input)
        {
            if (await _farmService.IsRegisteredAsync(input.Name))
            {
                {
                    _outputPort.FarmAlreadyRegistered($"Farm {input.Name} already exists");
                    return;
                }
            }

            var farm = await _farmService.RegisterFarmAsync(input.Name, input.Area, input.InscricaoEstadual);

            await _unitOfWork.SaveAsync();

            BuildOutput(farm);
        }