public ActionResult Put([FromBody] AlunoViewModel aluno)
        {
            /*Atualiza os dados do Logradouro do Cliente*/
            if (aluno.enderecos != null)
            {
                foreach (var e in aluno.enderecos)
                {
                    AlunoLogradouroViewModel LograView = new AlunoLogradouroViewModel();
                    LograView.ID_ALUNO_LOGRADOURO = e.ID_ALUNO_LOGRADOURO;
                    LograView.ID_ALUNO            = aluno.ID_ALUNO;
                    LograView.ID_LOGRADOURO       = e.ID_LOGRADOURO;
                    LograView.NR_LOGRADOURO       = e.NR_LOGRADOURO;
                    LograView.CPL_LOGRADOURO      = e.CPL_LOGRADOURO;
                    LograView.PONTO_REFERENCIA    = e.PONTO_REFERENCIA;
                    LograView.ID_USU     = aluno.ID_USU;
                    LograView.DT_CAD     = aluno.DT_CAD;
                    LograView.DT_ULT_ALT = DateTime.Now;
                    var existelogradouro = appserviceLogra.ExisteLogradouroCadastrado(e.ID_ALUNO_LOGRADOURO);
                    if (existelogradouro)
                    {
                        appserviceLogra.Atualizar(LograView);
                    }
                    else
                    {
                        appserviceLogra.Inserir(LograView);
                    }
                }
            }

            /*Atualiza os dados do Contato do Cliente*/
            foreach (var c in aluno.contatos)
            {
                AlunoContatoViewModel ContatoView = new AlunoContatoViewModel();
                ContatoView.ID_CONTATO      = c.ID_CONTATO;
                ContatoView.ID_ALUNO        = aluno.ID_ALUNO;
                ContatoView.ID_TIPO_CONTATO = c.ID_TIPO_CONTATO;
                ContatoView.DS_CONTATO      = c.DS_CONTATO;
                ContatoView.ID_USU          = aluno.ID_USU;
                ContatoView.DT_CAD          = aluno.DT_CAD;
                ContatoView.DT_ULT_ALT      = DateTime.Now;
                var existecontato = appserviceContato.ExisteContatoCadastrado(c.ID_CONTATO);
                if (existecontato)
                {
                    appserviceContato.Atualizar(ContatoView);
                }
                else
                {
                    appserviceContato.Inserir(ContatoView);
                }
            }

            return(TratarRetorno(appservice.Atualizar(aluno)));
        }
        public ConfigurationProfile()
        {
            this.AllowNullCollections = true;

            // PrescritorViewModel.Mapping(this);
            // PedidosLojaViewModel.Mapping(this);
            // PedidosLojaProdViewModel.Mapping(this);
            //	FarmaciaPopularViewModel.Mapping(this);

            AlunoViewModel.Mapping(this);
            AlunoLogradouroViewModel.Mapping(this);
            AlunoContatoViewModel.Mapping(this);

            LogradouroViewModel.Mapping(this);

            EscolaViewModel.Mapping(this);
            EscolaLogradouroViewModel.Mapping(this);
            EscolaContatoViewModel.Mapping(this);
        }
        public ActionResult Post([FromBody] AlunoViewModel aluno)
        {
            var inserirAluno = appservice.InserirRetornaModel(aluno);
            int ID_ALUNO     = inserirAluno.ID;

            if (aluno.enderecos != null)
            {
                /*Insere os dados do Logradouro do Cliente*/
                foreach (var e in aluno.enderecos)
                {
                    AlunoLogradouroViewModel LograView = new AlunoLogradouroViewModel();
                    LograView.ID_ALUNO         = ID_ALUNO;
                    LograView.ID_LOGRADOURO    = e.ID_LOGRADOURO;
                    LograView.NR_LOGRADOURO    = e.NR_LOGRADOURO;
                    LograView.CPL_LOGRADOURO   = e.CPL_LOGRADOURO;
                    LograView.PONTO_REFERENCIA = e.PONTO_REFERENCIA;
                    LograView.ID_USU           = aluno.ID_USU;
                    LograView.DT_CAD           = aluno.DT_CAD;
                    appserviceLogra.Inserir(LograView);
                }
            }

            /*Insere os dados do Contato do Cliente*/
            foreach (var c in aluno.contatos)
            {
                AlunoContatoViewModel ContatoView = new AlunoContatoViewModel();
                ContatoView.ID_ALUNO        = ID_ALUNO;
                ContatoView.ID_TIPO_CONTATO = c.ID_TIPO_CONTATO;
                ContatoView.DS_CONTATO      = c.DS_CONTATO;
                ContatoView.ID_USU          = aluno.ID_USU;
                ContatoView.DT_CAD          = aluno.DT_CAD;
                appserviceContato.Inserir(ContatoView);
            }


            return(TratarRetorno(inserirAluno));
        }