Beispiel #1
0
        public int CrearOfertaAccesorio(OfertaAccesorio OfertaAccesorio)
        {
            int idGenerado = 0;

            if (OfertaAccesorio.IdUsuarioAlta == 0)
            {
                OfertaAccesorio.IdUsuarioAlta = 1;
            }

            string connectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
            Engine engine           = new Engine(connectionString);

            StringBuilder comando = new StringBuilder();

            comando.Append("insert into OfertaAccesorios ");
            comando.Append(" (titulo, resumen, descripcion, locacion, precio, usuarioalta, fechaAlta) ");
            comando.Append(" values ");
            comando.Append(" ('" + OfertaAccesorio.Titulo + "','" + OfertaAccesorio.Resumen + "','" + OfertaAccesorio.Descripcion + "', '" + OfertaAccesorio.Locacion + "', '" + OfertaAccesorio.Precio + "', " + OfertaAccesorio.IdUsuarioAlta + ", NOW()) ");

            int resultado = engine.Execute(comando.ToString());

            if (resultado > 0)
            {
                idGenerado = CommonService.GetLastIdFromTable("OfertaAccesorios");
            }

            return(idGenerado);
        }
Beispiel #2
0
        public OfertaAccesorio GetOferta(int id)
        {
            OfertaAccesorio ofertaResultado = new OfertaAccesorio();

            OfertaAccesoriosService ofertaService = new OfertaAccesoriosService();

            ofertaResultado = ofertaService.GetOfertaAccesorio(id);

            return(ofertaResultado);
        }
Beispiel #3
0
        public List <OfertaAccesorio> GetOfertaAccesorios(string param)
        {
            List <OfertaAccesorio> resultado = new List <OfertaAccesorio>();

            string connectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
            Engine engine           = new Engine(connectionString);

            StringBuilder query = new StringBuilder();

            query.Append("select OfertaAccesorios.Id, OfertaAccesorios.Titulo, OfertaAccesorios.Resumen, OfertaAccesorios.Descripcion, OfertaAccesorios.Locacion, OfertaAccesorios.UsuarioAlta, OfertaAccesorios.FechaAlta ");
            query.Append(" , autor.Id as IdAutor, autor.Nombres, autor.Apellido1, autor.Apellido2 ");
            query.Append(" from OfertaAccesorios");
            query.Append(" inner join usuarios autor on OfertaAccesorios.UsuarioAlta = autor.Id ");
            query.Append(" where OfertaAccesorios.fechabaja is null  ");

            if (!string.IsNullOrEmpty(param))
            {
                query.Append(" and (OfertaAccesorios.titulo like '%" + param + "%' OR OfertaAccesorios.resumen like '%" + param + "%' OR OfertaAccesorios.descripcion like '%" + param + "%' ");
            }

            DataTable table = engine.Query(query.ToString());

            foreach (DataRow dr in table.Rows)
            {
                OfertaAccesorio OfertaAccesorioFila = new OfertaAccesorio();

                OfertaAccesorioFila.Id                = int.Parse(dr["Id"].ToString());
                OfertaAccesorioFila.Titulo            = dr["Titulo"].ToString();
                OfertaAccesorioFila.Resumen           = dr["Resumen"].ToString();
                OfertaAccesorioFila.Descripcion       = dr["Descripcion"].ToString();
                OfertaAccesorioFila.Locacion          = dr["Locacion"].ToString();
                OfertaAccesorioFila.Autor             = dr["Nombres"].ToString() + " " + dr["Apellido1"].ToString() + " " + dr["Apellido2"].ToString();
                OfertaAccesorioFila.IdUsuarioAlta     = int.Parse(dr["UsuarioAlta"].ToString());
                OfertaAccesorioFila.FechaAlta         = DateTime.Parse(dr["FechaAlta"].ToString());
                OfertaAccesorioFila.RutaFotoAutor     = new FotografiaService().ObtenerFotoPrincipal(OfertaAccesorioFila.IdUsuarioAlta).RutaFoto;
                OfertaAccesorioFila.RutaFotoPrincipal = new FotografiaService().ObtenerFotoPrincipalOferta(OfertaAccesorioFila.Id).RutaFoto;
                OfertaAccesorioFila.Fotografias       = new FotografiaService().ObtenerFotosOfertaAccesorio(OfertaAccesorioFila.Id);
                // OfertaAccesorioFila.Apuntados = GetApuntadosOfertaAccesorio(OfertaAccesorioFila.Id);
                resultado.Add(OfertaAccesorioFila);
            }

            return(resultado);
        }
Beispiel #4
0
        public int Guardar(OfertaAccesorio value)
        {
            OfertaAccesorio ofertaGuardado = new OfertaAccesorio();

            int resultado = 0;

            ofertaGuardado.Titulo                = value.Titulo;
            ofertaGuardado.Resumen               = value.Resumen;
            ofertaGuardado.Descripcion           = value.Descripcion;
            ofertaGuardado.IdUsuarioAlta         = value.IdUsuarioAlta;
            ofertaGuardado.IdUsuarioModificacion = value.IdUsuarioModificacion;
            ofertaGuardado.Locacion              = value.Locacion;
            ofertaGuardado.Precio                = value.Precio;

            OfertaAccesoriosService ofertaService = new OfertaAccesoriosService();

            if (value.Id == 0)
            {
                resultado = ofertaService.CrearOfertaAccesorio(ofertaGuardado);
                value.Id  = resultado;

                if (value.Fotografias != null)
                {
                    foreach (Fotografia fotografia in value.Fotografias)
                    {
                        fotografia.IdQuedada = value.Id;
                    }
                }
            }
            else
            {
                ofertaGuardado.Id = value.Id;
                resultado         = ofertaService.EditarOfertaAccesorio(ofertaGuardado);
            }

            FotografiaService fotografiaService = new FotografiaService();

            fotografiaService.AdjuntarFotografiasOfertas(value.Fotografias);

            return(ofertaGuardado.Id);
        }
Beispiel #5
0
        public int EditarOfertaAccesorio(OfertaAccesorio OfertaAccesorio)
        {
            string connectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
            Engine engine           = new Engine(connectionString);

            StringBuilder comando = new StringBuilder();

            comando.Append("update OfertaAccesorios set ");
            comando.Append("titulo = '" + OfertaAccesorio.Titulo + "'");
            comando.Append(", resumen = '" + OfertaAccesorio.Resumen + "'");
            comando.Append(", descripcion = '" + OfertaAccesorio.Descripcion + "'");
            comando.Append(", precio = '" + OfertaAccesorio.Precio + "'");
            comando.Append(", locacion = '" + OfertaAccesorio.Locacion + "'");
            comando.Append(", fechamodificacion =  NOW()");
            comando.Append(", usuariomodificacion = " + OfertaAccesorio.IdUsuarioModificacion);
            comando.Append(" where id=" + OfertaAccesorio.Id);

            int resultado = engine.Execute(comando.ToString());

            return(OfertaAccesorio.Id);
        }
Beispiel #6
0
        public OfertaAccesorio GetOfertaAccesorio(int idOfertaAccesorio)
        {
            OfertaAccesorio resultado = new OfertaAccesorio();

            string connectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
            Engine engine           = new Engine(connectionString);

            StringBuilder query = new StringBuilder();

            query.Append("select OfertaAccesorios.Id, OfertaAccesorios.Titulo, OfertaAccesorios.Resumen, OfertaAccesorios.Descripcion, OfertaAccesorios.Locacion, OfertaAccesorios.Precio, OfertaAccesorios.FechaAlta ");
            query.Append(" , autor.Id as IdAutor, autor.Nombres, autor.Apellido1, autor.Apellido2 ");
            query.Append(" from OfertaAccesorios");
            query.Append(" inner join usuarios autor on OfertaAccesorios.UsuarioAlta = autor.Id ");
            query.Append("where OfertaAccesorios.Id = " + idOfertaAccesorio);


            DataTable table = engine.Query(query.ToString());

            foreach (DataRow dr in table.Rows)
            {
                resultado.Id            = int.Parse(dr["Id"].ToString());
                resultado.Titulo        = dr["Titulo"].ToString();
                resultado.Resumen       = dr["Resumen"].ToString();
                resultado.Descripcion   = dr["Descripcion"].ToString();
                resultado.Locacion      = dr["Locacion"].ToString();
                resultado.Autor         = dr["Nombres"].ToString() + " " + dr["Apellido1"].ToString() + " " + dr["Apellido2"].ToString();
                resultado.Precio        = dr["Precio"].ToString();
                resultado.IdUsuarioAlta = int.Parse(dr["IdAutor"].ToString());
                resultado.FechaAlta     = DateTime.Parse(dr["FechaAlta"].ToString());
                //resultado.Apuntados = GetApuntadosOfertaAccesorio(resultado.Id);
                FotografiaService fotografiaService = new FotografiaService();
                resultado.Fotografias = fotografiaService.ObtenerFotosOfertaAccesorio(resultado.Id);
            }

            return(resultado);
        }