Beispiel #1
0
        public bool AtualidarCliente(ClienteEntity oCliente)
        {
            bool returnSucess = false;



            try
            {
                using (var myModel = new ContextModel.Model())
                {
                    ClienteEntity updateCliente = new ClienteEntity();



                    myModel.Update(oCliente);

                    myModel.SaveChanges();

                    returnSucess = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(returnSucess);
        }
        public List <ClienteLogradouroEntity> ListarLogradouroCliente(ClienteLogradouroEntity oClienteLogradouro)
        {
            List <ClienteLogradouroEntity> returnListClienteLogradouroEntity = new List <ClienteLogradouroEntity>();



            try
            {
                using (var myModel = new ContextModel.Model())
                {
                    var retorno = myModel.Query <ClienteLogradouroEntity>().ToList().Where(x => x.IDCliente == oClienteLogradouro.IDCliente);

                    foreach (var item in retorno)
                    {
                        returnListClienteLogradouroEntity.Add(new ClienteLogradouroEntity()
                        {
                            ID = item.ID, IDCliente = item.IDCliente, IDLogradouro = item.IDLogradouro
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(returnListClienteLogradouroEntity);
        }
Beispiel #3
0
        public List <ClienteEntity> ListarClientes(ClienteEntity oCliente)
        {
            List <ClienteEntity> returnListClienteEntity = new List <ClienteEntity>();



            try
            {
                using (var myModel = new ContextModel.Model())
                {
                    returnListClienteEntity = myModel.Query <ClienteEntity>().ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(returnListClienteEntity);
        }
        public List <LogradouroEntity> ListarLogradouros(LogradouroEntity oLogradouro)
        {
            List <LogradouroEntity> returnListLogradouroEntity = new List <LogradouroEntity>();



            try
            {
                using (var myModel = new ContextModel.Model())
                {
                    returnListLogradouroEntity = myModel.Query <LogradouroEntity>().ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(returnListLogradouroEntity);
        }
        internal List <LogradouroEntity> SelecionarLogradouroPorCliente(ClienteEntity myCliente, LogradouroEntity myLogradouro)
        {
            List <LogradouroEntity> retorno = new  List <LogradouroEntity>();

            try
            {
                using (var myModel = new ContextModel.Model())
                {
                    retorno = myModel.Query <LogradouroEntity>().ToList().Where(x => x.CEP == myLogradouro.CEP && x.Bairro == myLogradouro.Bairro && x.Endereco == myLogradouro.Endereco).ToList();
                    retorno = (from item in retorno
                               join item2 in myModel.Query <ClienteLogradouroEntity>().ToList()
                               on item.ID equals item2.IDLogradouro
                               where item2.IDCliente == myCliente.ID
                               select item).ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(retorno);
        }
Beispiel #6
0
        public bool IncluirCliente(ClienteEntity oCliente)
        {
            bool returnSucess = false;



            try
            {
                using (ContextModel.Model myModel = new ContextModel.Model())
                {
                    myModel.Add(oCliente);

                    myModel.SaveChanges();

                    returnSucess = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(returnSucess);
        }
        public bool IncluirLogradouro(LogradouroEntity oLogradouro)
        {
            bool returnSucess = false;



            try
            {
                using (ContextModel.Model myModel = new ContextModel.Model())
                {
                    myModel.Add(oLogradouro);

                    myModel.SaveChanges();

                    returnSucess = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(returnSucess);
        }