internal static int GuardarInmueble(Inmueble inmueble, bool importado = false)
 {
     try
     {
         if (inmueble.Id == 0)
         {
             inmueble.Id = GetNextId(inmueble);
             DAOBase.CreateEntity(inmueble);
             return(inmueble.Id);
         }
         else
         {
             if (importado)
             {
                 DAOBase.CreateEntity(inmueble);
                 return(inmueble.Id);
             }
             DAOBase.UpdateEntity(inmueble);
             return(inmueble.Id);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
 public bool EliminarInteresado(Interesado interesado)
 {
     try
     {
         return(DAOBase.DeleteEntity(interesado));
     }
     catch (Exception ex)
     {
         EmailHelper.EnviarNotificacion(ex);
         throw ex;
     }
 }
Пример #3
0
 public bool EliminarVendedor(Vendedor vendedor)
 {
     try
     {
         return(DAOBase.DeleteEntity(vendedor));
     }
     catch (Exception ex)
     {
         EmailHelper.EnviarNotificacion(ex);
         throw ex;
     }
 }
        internal static bool DeleteInmueble(Inmueble inmueble)
        {
            int inmuebleId = inmueble.Id;

            List <Foto> fotos = FotoDAO.GetFotosDelInmueble(inmuebleId);

            for (int i = 0; i < fotos.Count; i++)
            {
                Foto foto = fotos[i];
                DAOBase.DeleteEntity(foto);
            }

            bool pudoEliminar = DAOBase.DeleteEntity(inmueble);

            return(pudoEliminar);
        }
        internal static List <Inmueble> BuscarInmuebles(Inmueble inmueble, decimal?precioDesde, decimal?precioHasta)
        {
            try
            {
                List <Inmueble> inmuebles = new List <Inmueble>();
                DataTable       dt        = DAOBase.GetDataTable(new Inmueble(), string.Empty);
                if (dt.Rows.Count > 0)
                {
                    inmuebles = LlenarInmuebles(new Inmueble(), dt);

                    inmuebles = inmuebles.Where(x => x.Operacion == inmueble.Operacion).ToList();
                    inmuebles = inmuebles.Where(x => x.Tipo == inmueble.Tipo).ToList();

                    //if (!string.IsNullOrEmpty(inmueble.Barrio))
                    //{
                    //    inmuebles = inmuebles.Where(x => x.Barrio.Contains(inmueble.Barrio)).ToList();
                    //}
                    //if (!string.IsNullOrEmpty(inmueble.Baños))
                    //{
                    //    inmuebles = inmuebles.Where(x => x.Baños.Contains(inmueble.Baños)).ToList();
                    //}
                    //if (!string.IsNullOrEmpty(inmueble.Dormitorios))
                    //{
                    //    inmuebles = inmuebles.Where(x => x.Dormitorios.Contains(inmueble.Dormitorios)).ToList();
                    //}
                    if (!string.IsNullOrEmpty(inmueble.Localidad))
                    {
                        inmuebles = inmuebles.Where(x => x.Localidad.Contains(inmueble.Localidad)).ToList();
                    }
                    if (precioDesde.HasValue)
                    {
                        inmuebles = inmuebles.Where(x => x.Precio > precioDesde.Value && x.Moneda == inmueble.Moneda).ToList();
                    }
                    if (precioHasta.HasValue)
                    {
                        inmuebles = inmuebles.Where(x => x.Precio < precioHasta.Value && x.Moneda == inmueble.Moneda).ToList();
                    }
                }

                return(inmuebles);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #6
0
 internal static void CrearInteresado(Interesado interesado)
 {
     try
     {
         if (interesado.Id == null || interesado.Id == 0)
         {
             interesado.Id = GetNextId(interesado);
             DAOBase.CreateEntity(interesado);
         }
         else
         {
             DAOBase.UpdateEntity(interesado);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 internal static void CrearVendedor(Vendedor vendedor)
 {
     try
     {
         if (vendedor.Id == null || vendedor.Id == 0)
         {
             vendedor.Id = GetNextId(vendedor);
             DAOBase.CreateEntity(vendedor);
         }
         else
         {
             DAOBase.UpdateEntity(vendedor);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #8
0
 internal static void CrearFoto(Foto foto)
 {
     try
     {
         if (foto.Id == null || foto.Id == 0)
         {
             foto.Id = GetNextId(foto);
             DAOBase.CreateEntity(foto);
         }
         else
         {
             DAOBase.UpdateEntity(foto);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #9
0
        internal static List <Interesado> GetInteresados()
        {
            try
            {
                //Instanciamos una lista de interesado que es la que vamos a retornar
                List <Interesado> interesado = new List <Interesado>();
                //Hasta aca la lista esta vacia

                //Le pedimos a la bd que nos de todos los interesado
                DataTable dt = DAOBase.GetDataTable(new Interesado(), string.Empty);
                if (dt.Rows.Count > 0)
                {
                    //Aca llenamos la lista de interesado
                    interesado = LlenarInteresados(new Interesado(), dt);
                }

                //Retornamos la lista de interesado
                return(interesado);
            }
            catch (Exception)
            {
                throw;
            }
        }
        internal static Vendedor Login(string email, string password)
        {
            try
            {
                List <Vendedor> vendedores = new List <Vendedor>();
                DataTable       dt         = DAOBase.GetDataTableWhere(new Vendedor(), string.Format("Email = '{0}' AND Password = '******'", email, password));

                if (dt.Rows.Count > 0)
                {
                    Vendedor vendedor = new Vendedor();
                    PoblarObjetoDesdeDataRow(vendedor, dt.Rows[0]);

                    return(vendedor);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        internal static List <Vendedor> GetVendedores()
        {
            try
            {
                //Instanciamos una lista de vendedores que es la que vamos a retornar
                List <Vendedor> vendedores = new List <Vendedor>();
                //Hasta aca la lista esta vacia

                //Le pedimos a la bd que nos de todos los Vendedores
                DataTable dt = DAOBase.GetDataTable(new Vendedor(), string.Empty);
                if (dt.Rows.Count > 0)
                {
                    //Aca llenamos la lista de vendedores
                    vendedores = LlenarVendedores(new Vendedor(), dt);
                }

                //Retornamos la lista de vendedores
                return(vendedores);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #12
0
        internal static List <Foto> GetFotosDelInmueble(int inmuebleId)
        {
            try
            {
                //Instanciamos una lista de Fotos que es la que vamos a retornar
                List <Foto> fotos = new List <Foto>();
                //Hasta aca la lista esta vacia

                //Le pedimos a la bd que nos de todos los Fotos
                DataTable dt = DAOBase.GetDataTableWhere(new Foto(), string.Format("InmuebleId = {0}", inmuebleId));
                if (dt.Rows.Count > 0)
                {
                    //Aca llenamos la lista de Fotos
                    fotos = LlenarFotos(new Foto(), dt);
                }

                //Retornamos la lista de vendedores
                return(fotos);
            }
            catch (Exception)
            {
                throw;
            }
        }