示例#1
0
        public async Task <IActionResult> Create(ClienteDTO clienteDTO)
        {
            if (ModelState.IsValid)
            {
                var userLogged = await usuarioServices.GetUserAsync();

                var trueCliente = new Cliente
                {
                    CPF      = clienteDTO.CPF,
                    Nome     = clienteDTO.Nome,
                    Birthday = clienteDTO.Birthday,
                    Sexo     = clienteDTO.Sexo,
                    Contato  = new Contato
                    {
                        Email    = clienteDTO.Contato.Email,
                        Telefone = clienteDTO.Contato.Telefone
                    },
                    UsuarioId = userLogged.Id
                };
                clienteServices.AddAsync(trueCliente);
                return(Ok(clienteDTO));
            }
            return(UnprocessableEntity(ModelState));
        }