Ejemplo n.º 1
0
        //---------------------------------------------------------------------------------------------------------------------------------------
        /// <summary> Construye el objeto y obtiene los datos de la base de datos </summary>
        public RecambiosFabricantesModel(string maker, HttpContext HttpCtx) : base(HttpCtx)
        {
            Maker = maker.Replace('-', ' ').ToUpper();

            var recambs = new Recambios(HttpCtx).FindByDatos($"fab-{Maker}/orden-categoria/rango-0-10000");

            MakerId = recambs.Filters.Fabricante.Id;

            var catTable = new Categorias(HttpCtx);

            GrupoItems grp     = null;
            int        lastCat = -1;

            foreach (var item in recambs.Items)
            {
                if (item.Categoria != lastCat)
                {
                    if (grp != null)
                    {
                        Grupos.Add(grp);
                    }
                    grp = new GrupoItems(item.Categoria, catTable.findNombre(item.Categoria));

                    lastCat = item.Categoria;
                }

                if (grp.Items.Count < 4)
                {
                    grp.Items.Add(item);
                }
            }

            if (grp != null)
            {
                Grupos.Add(grp);
            }
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------------------------------------------------------------------------
        /// <summary> Construye el objeto y obtiene los datos de la base de datos </summary>
        public RecambiosCocheModel(int cocheId, HttpContext HttpCtx) : base(HttpCtx)
        {
            if (!fillCocheDatos(cocheId, HttpCtx))
            {
                return;
            }

            var catTable = new Categorias(HttpCtx);
            var Items    = new Recambios(HttpCtx).FindByDatos($"Mar-{MarcaId}/Mod-{ModeloId}/Mot-{MotorId}/orden-categoria/rango-0-10000").Items;

            GrupoItems grp     = null;
            int        lastCat = -1;

            foreach (var item in Items)
            {
                if (item.Categoria != lastCat)
                {
                    if (grp != null)
                    {
                        Grupos.Add(grp);
                    }
                    grp = new GrupoItems(item.Categoria, catTable.findNombre(item.Categoria));

                    lastCat = item.Categoria;
                }

                if (grp.Items.Count < 4)
                {
                    grp.Items.Add(item);
                }
            }

            if (grp != null)
            {
                Grupos.Add(grp);
            }
        }