示例#1
0
        /// <summary>
        /// Sincroniza una lista Entity en una de Negocio
        /// </summary>
        /// <param name="listaDatos"></param>
        /// <returns>List<Cliente></returns>
        private List <Cliente> SyncList(List <Entity.Cliente> listaDatos)
        {
            List <Cliente> list = new List <Cliente>();

            try
            {
                foreach (var x in listaDatos)
                {
                    Cliente cliente = new Cliente();
                    CommonBC.Syncronize(x, cliente);

                    Sexo sexo = new Sexo();
                    sexo.Id = x.IdSexo;
                    if (sexo.Read())
                    {
                        cliente.Sexo = sexo;
                    }
                    else
                    {
                        throw new Exception("Error al leer el sexo.");
                    }

                    EstadoCivil estado = new EstadoCivil();
                    estado.Id = x.IdEstado;
                    if (estado.Read())
                    {
                        cliente.EstadoCivil = estado;
                    }
                    else
                    {
                        throw new Exception("Error al leer el Estado.");
                    }

                    list.Add(cliente);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error Sincronizar Lista. " + ex.Message);
            }

            return(list);
        }
示例#2
0
        private List <Plan> GenerarListado(List <BeLife.Datos.Plan> listadoDatos, String idTipo)
        {
            List <Plan> listadoPlan = new List <Plan>();

            Console.WriteLine(idTipo + "compara");
            foreach (Datos.Plan dato in listadoDatos)
            {
                Console.WriteLine(dato.IdTipoContrato);

                if (dato.IdTipoContrato == int.Parse(idTipo))
                {
                    Plan plan = new Plan();
                    CommonBC.Syncronize(dato, plan);
                    Console.WriteLine(plan.ToString() + "sddsfsfsd");
                    listadoPlan.Add(plan);
                }
            }

            return(listadoPlan);
        }
示例#3
0
        /// <summary>
        /// Sincroniza una lista Entity en una de Negocio
        /// </summary>
        /// <param name="listaDatos"></param>
        /// <returns>List<Sexo></returns>
        private List <Plan> SyncList(List <Entity.Plan> listaDatos)
        {
            try
            {
                List <Plan> list = new List <Plan>();

                foreach (var x in listaDatos)
                {
                    Plan plan = new Plan();
                    CommonBC.Syncronize(x, plan);
                    list.Add(plan);
                }

                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception("Error Sincronizar listas. " + ex.Message);
            }
        }
示例#4
0
        //C.R.U.D. Borrar contrato

        public bool DeleteContrato()
        {
            Datos.BeLifeEntities bbdd = new Datos.BeLifeEntities();

            try
            {
                Datos.Contrato contrato = bbdd.Contrato.First(e => e.RutCliente == RutCliente);

                CommonBC.Syncronize(this, contrato);

                bbdd.SaveChanges();

                return(true);
            }

            catch (Exception)
            {
                return(false);
            }
        }
示例#5
0
        /// <summary>
        /// Sincroniza una lista Entity en una de Negocio
        /// </summary>
        /// <param name="listaDatos"></param>
        /// <returns>List<Vivienda></returns>
        private List <Vivienda> SyncList(List <Entity.Vivienda> listaDatos)
        {
            List <Vivienda> list = new List <Vivienda>();

            try
            {
                foreach (var x in listaDatos)
                {
                    Vivienda vivienda = new Vivienda();
                    CommonBC.Syncronize(x, vivienda);

                    list.Add(vivienda);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error Sincronizar Lista. " + ex.Message);
            }

            return(list);
        }
示例#6
0
        /// <summary>
        /// Busca en la tabla Modelo algun registro que su Id sea el mismo que el parametro y lo retorna.
        /// </summary>
        /// <param name="id">int Id Modelo</param>
        /// <returns>Marca marca</returns>
        public bool Read()
        {
            BeLifeEntities bbdd = new BeLifeEntities();

            try
            {
                Entity.ModeloVehiculo modelo = bbdd.ModeloVehiculo.Where(x => x.Id == this.Id).FirstOrDefault();
                if (modelo != null)
                {
                    CommonBC.Syncronize(modelo, this);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al leer modelo." + ex.Message);
            }
        }
示例#7
0
        /// <summary>
        /// Busca en la tabla TipoContrato algun registro que su Id sea el mismo que el parametro y lo retorna.
        /// </summary>
        /// <param name="id">int Id TipoContrato</param>
        /// <returns>bool</returns>
        public bool Read()
        {
            BeLifeEntities bbdd = new BeLifeEntities();

            try
            {
                Entity.TipoContrato tipoContrato = bbdd.TipoContrato.Where(x => x.Id == this.Id).FirstOrDefault();
                if (tipoContrato != null)
                {
                    CommonBC.Syncronize(tipoContrato, this);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al leer tipo de contrato." + ex.Message);
            }
        }
示例#8
0
        /// <summary>
        /// Busca en la tabla Plan algun registro que su IdPlan sea el mismo que el parametro y lo retorna.
        /// </summary>
        /// <param name="id">string Id del Plan</param>
        /// <returns>Plan plan</returns>
        public bool Read()
        {
            BeLifeEntities bbdd = new BeLifeEntities();

            try
            {
                Entity.Plan pla = bbdd.Plan.Where(x => x.Id == this.Id).FirstOrDefault();
                if (pla != null)
                {
                    CommonBC.Syncronize(pla, this);
                    return(true);
                }
                else
                {
                    throw new Exception("El Plan no existe");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al leer Plan. " + ex.Message);
            }
        }
示例#9
0
        /// <summary>
        /// Busca en la tabla EstadoCivil algun registro que su IdEstadoCivil sea el mismo que el parametro y lo retorna.
        /// </summary>
        /// <param name="id">string Id del Estado Civil</param>
        /// <returns>EstadoCivil estado</returns>
        public bool Read()
        {
            BeLifeEntities bbdd = new BeLifeEntities();

            try
            {
                Entity.EstadoCivil e = bbdd.EstadoCivil.Where(x => x.Id == this.Id).FirstOrDefault();
                if (e != null)
                {
                    CommonBC.Syncronize(e, this);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al leer sexo." + ex.Message);
            }
        }
示例#10
0
        /// <summary>
        /// Busca en la tabla Comuna algun registro que su Id sea el mismo que el parametro y lo retorna.
        /// </summary>
        /// <param name="id">int Id Comuna</param>
        /// <returns>Comuna comuna</returns>
        public bool Read()
        {
            BeLifeEntities bbdd = new BeLifeEntities();

            try
            {
                Entity.Comuna comuna = bbdd.Comuna.Where(x => x.Id == this.Id).FirstOrDefault();
                if (comuna != null)
                {
                    CommonBC.Syncronize(comuna, this);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al leer comuna." + ex.Message);
            }
        }
示例#11
0
        /// <summary>
        /// Busca en la tabla Sexo algun registro que su IdSexo sea el mismo que el parametro y lo retorna.
        /// </summary>
        /// <param name="id">string Id del Sexo</param>
        /// <returns>Sexo sexo</returns>
        public bool Read()
        {
            BeLifeEntities bbdd = new BeLifeEntities();

            try
            {
                Entity.Sexo s = bbdd.Sexo.Where(x => x.Id == this.Id).FirstOrDefault();
                if (s != null)
                {
                    CommonBC.Syncronize(s, this);
                    return(true);
                }
                else
                {
                    return(false);
                    //throw new Exception("El Id : {0}, no existe." + Id);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al leer sexo." + ex.Message);
            }
        }
示例#12
0
        /// <summary>
        /// Crea un registro de Cliente en la BBDD
        /// </summary>
        /// <returns></returns>
        public bool Create()
        {
            bool crea = false;

            try
            {
                BeLifeEntities bbdd = new BeLifeEntities();
                Entity.Cliente cli  = new Entity.Cliente();

                //Ve si no existe el cliente para poder crearlo.
                if (!this.Read())
                {
                    //Sincroniza datos
                    CommonBC.Syncronize(this, cli);
                    CommonBC.Syncronize(this.Sexo, cli.Sexo);
                    cli.IdSexo = this.Sexo.Id;
                    CommonBC.Syncronize(this.EstadoCivil, cli.EstadoCivil);
                    cli.IdEstado = this.EstadoCivil.Id;

                    //Guarda los cambios
                    bbdd.Cliente.Add(cli);
                    bbdd.SaveChanges();
                    crea = true;
                }
                else
                {
                    throw new Exception("El cliente ya existe.");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error Crear Cliente. " + ex.Message);
            }

            return(crea);
        }
示例#13
0
        //Lista
        private List <Cliente> GenerarListado(List <Datos.Cliente> listaDatos)
        {
            //se crea lista para para retornar clientes
            List <Cliente> listaRegistro = new List <Cliente>();


            //un foreach que recorre la lista de cliente de la base de datos que inserta hacia la lista de cliente
            foreach (Datos.Cliente datos in listaDatos)

            {
                //se crea un objeto cliente
                Cliente cliente = new Cliente();
                //se envia un cliente de base de dato y un cliente y retorna un cliente nuevo
                CommonBC.Syncronize(datos, cliente);
                //le cambio el id por descripccion que me trajo el CommonBC.Syncronize(datos, cliente);
                cliente.IdSexo        = datos.Sexo.Descripcion;
                cliente.IdEstadoCivil = datos.EstadoCivil.Descripcion;
                //se inserta cliente en la lista de cliente
                listaRegistro.Add(cliente);
            }

            //retorna la lista
            return(listaRegistro);
        }