Example #1
0
        public Task <HttpResponseMessage> Put(Guid id, [FromBody] dynamic body)
        {
            //Entradas de dados devem ser revistas quando for criado o Frontend

            var clienteCommand = new ClienteCommand(
                nome: (string)body.nome,
                cpf: (string)body.cpf,
                celular: (string)body.celular,
                email: (string)body.email,
                dataDeNascimento: (DateTime?)body.dataDeNascimento,
                imagem: (string)body.imagem
                );
            var enderecoCommand = new EnderecoCommand(
                logradouro: (string)body.endereco.logradouro,
                numero: (string)body.endereco.numero,
                complemento: (string)body.endereco.complemento,
                bairro: (string)body.endereco.bairro,
                cep: (string)body.endereco.cep,
                idCidade: (Guid)body.endereco.cidadeId,
                idEstado: (Guid)body.endereco.estadoId
                );

            clienteCommand.Endereco = enderecoCommand;
            clienteCommand.IdPessoa = id;

            var cliente = _clienteApp.Atualizar(clienteCommand);

            return(CreateResponse(HttpStatusCode.OK, cliente));
        }
Example #2
0
        public Task <HttpResponseMessage> Put(Guid id, [FromBody] dynamic body)
        {
            var funcionarioCommand = new FuncionarioCommand(
                nome: (string)body.nome,
                cpf: (string)body.cpf,
                celular: (string)body.celular,
                email: (string)body.email,
                funcao: (string)body.funcao,
                idEstabelecimento: (Guid)body.estabelecimentoId,
                imagem: (string)body.imagem
                );
            var enderecoCommand = new EnderecoCommand(
                logradouro: (string)body.endereco.logradouro,
                numero: (string)body.endereco.numero,
                complemento: (string)body.endereco.complemento,
                bairro: (string)body.endereco.bairro,
                cep: (string)body.endereco.cep,
                idCidade: (Guid)body.endereco.cidadeId,
                idEstado: (Guid)body.endereco.estadoId
                );

            funcionarioCommand.Endereco = enderecoCommand;
            funcionarioCommand.IdPessoa = id;

            var funcionario = _funcionarioApp.Atualizar(funcionarioCommand);

            return(CreateResponse(HttpStatusCode.OK, funcionario));
        }
        public Task <HttpResponseMessage> Post([FromBody] dynamic body)
        {
            var estabelecimentoCommand = new EstabelecimentoCommand(
                razaoSocial: (string)body.estabelecimento.razaoSocial,
                nomeFantasia: (string)body.estabelecimento.nomeFantasia,
                email: (string)body.estabelecimento.email,
                cnpj: (string)body.estabelecimento.cnpj,
                telefone: (string)body.estabelecimento.telefone,
                logo: (string)body.estabelecimento.logo,
                descricao: (string)body.estabelecimento.descricao
                );
            var enderecoJuridicoCommand = new EnderecoJuridicoCommand(
                logradouro: (string)body.estabelecimento.logradouro,
                numero: (string)body.estabelecimento.numero,
                complemento: (string)body.estabelecimento.complemento,
                bairro: (string)body.estabelecimento.bairro,
                cep: (string)body.estabelecimento.cep,
                idCidade: (Guid)body.estabelecimento.idCidade,
                idEstado: (Guid)body.estabelecimento.idEstado
                );
            var funcionarioCommand = new FuncionarioCommand(
                nome: (string)body.nome,
                cpf: (string)body.cpf,
                celular: (string)body.celular,
                email: (string)body.email,
                funcao: (string)body.funcao,
                idEstabelecimento: null,
                imagem: (string)body.imagem
                );
            var enderecoCommand = new EnderecoCommand(
                logradouro: (string)body.logradouro,
                numero: (string)body.numero,
                complemento: (string)body.complemento,
                bairro: (string)body.bairro,
                cep: (string)body.cep,
                idCidade: (Guid)body.idCidade,
                idEstado: (Guid)body.idEstado
                );
            var usuarioCommand = new UsuarioCommand(
                email: (string)body.usuario.email,
                senha: (string)body.usuario.confirmarSenha,
                perfil: (int)body.usuario.perfil,
                estaAtivo: (bool)body.usuario.estaAtivo,
                idPessoa: null
                );

            estabelecimentoCommand.EnderecoJuridico = enderecoJuridicoCommand;
            funcionarioCommand.Endereco             = enderecoCommand;
            funcionarioCommand.Estabelecimento      = estabelecimentoCommand;
            funcionarioCommand.Usuario = usuarioCommand;

            var estabelecimento = _estabelecimentoApp.Cadastrar(funcionarioCommand);

            return(CreateResponse(HttpStatusCode.Created, estabelecimento));
        }
Example #4
0
        public static EnderecoCommand ToModelDomain(Endereco endereco)
        {
            if (endereco == null)
            {
                return(null);
            }

            var enderecoCommand = new EnderecoCommand(
                endereco.Logradouro,
                endereco.Numero,
                endereco.Complemento,
                endereco.Bairro,
                endereco.Cep.CepCod,
                endereco.CidadeId,
                endereco.EstadoId);

            enderecoCommand.IdEndereco = endereco.IdEndereco;
            enderecoCommand.Estado     = EstadoAdapter.ToModelDomain(endereco.Estado);
            enderecoCommand.Cidade     = CidadeAdapter.ToModelDomain(endereco.Cidade);

            return(enderecoCommand);
        }
Example #5
0
        public static Endereco ToDomainModel(EnderecoCommand enderecoCommand)
        {
            if (enderecoCommand == null)
            {
                return(null);
            }

            var endereco = new Endereco(
                enderecoCommand.Logradouro,
                enderecoCommand.Complemento,
                enderecoCommand.Numero,
                enderecoCommand.Bairro,
                enderecoCommand.CidadeId,
                enderecoCommand.EstadoId,
                enderecoCommand.Cep);

            if (enderecoCommand.IdEndereco != null)
            {
                endereco.IdEndereco = enderecoCommand.IdEndereco.Value;
            }

            return(endereco);
        }