Пример #1
0
        public SkuViewerModel Build(long idCat, int sort)
        {
            var model = new SkuViewerModel();
            var cat   = dataService.GetStaticCategoryById(idCat);

            if (cat != null)
            {
                model.IdCat = cat.id;
                model.Name  = cat.name;
                switch (sort)
                {
                case 1:    //сорт от А до Я
                    model.skuList = ListSkuByCategory(cat).OrderBy(it => it.name).ToList();
                    break;

                case 2:    //сорт от Я до А
                    model.skuList = ListSkuByCategory(cat).OrderByDescending(it => it.name).ToList();
                    break;

                case 3:    //сорт по цене Возростание
                    model.skuList = ListSkuByCategory(cat).OrderBy(it => it.priceAct).ToList();
                    break;

                case 4:    //сорт по цене Убывание
                    model.skuList = ListSkuByCategory(cat).OrderByDescending(it => it.priceAct).ToList();
                    break;

                default:
                    model.skuList = ListSkuByCategory(cat).ToList();
                    break;
                }
            }
            model.menu = BuildMenu();
            return(model);
        }
Пример #2
0
 public SkuViewerModel Build(long idCat, int sort)
 {
     var model = new SkuViewerModel();
     var cat = dataService.GetStaticCategoryById(idCat);
     if (cat!=null)
     {
         model.IdCat = cat.id;
         model.Name=cat.name;
         switch (sort)
         {
             case 1://сорт от А до Я
                 model.skuList = ListSkuByCategory(cat).OrderBy(it => it.name).ToList();
                 break;
             case 2://сорт от Я до А
                 model.skuList = ListSkuByCategory(cat).OrderByDescending(it=>it.name).ToList();
                 break;
             case 3://сорт по цене Возростание
                 model.skuList = ListSkuByCategory(cat).OrderBy(it => it.priceAct).ToList();
                 break;
             case 4://сорт по цене Убывание
                 model.skuList = ListSkuByCategory(cat).OrderByDescending(it => it.priceAct).ToList();
                 break;
             default:
                 model.skuList = ListSkuByCategory(cat).ToList();
                 break;
         }
     }
     model.menu = BuildMenu();
     return model;
 }