Exemplo n.º 1
0
        public async Task <IActionResult> Post([FromServices] CadastrarEmpresaPresenter presenter,
                                               [FromServices] CadastrarEmpresaCasoDeUso casoDeUso,
                                               [FromBody] CadastrarEmpresaRequest request)
        {
            var input = new CadastrarEmpresaInput(request.UF, request.NomeFantasia, request.CNPJ);
            await casoDeUso.Execute(input);

            return(presenter.ViewModel);
        }
        public async Task <IActionResult> Adicionar([FromBody] CadastrarEmpresaRequest request)
        {
            try
            {
                string proprietarioClaims = _httpContextAccessor.HttpContext.User.FindFirst("Proprietario").Value;
                AutenticarProprietarioResponse proprietarioResponse = JsonConvert.DeserializeObject <AutenticarProprietarioResponse>(proprietarioClaims);
                request.FkProprietario = proprietarioResponse.Id;

                var response = await _mediator.Send(request, CancellationToken.None);

                return(await ResponseAsync(response));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }