Exemple #1
0
        public List <ProductTypeDO> GetProductTypeFAC(int parent)
        {
            using (var db = new ProjectWebEntities())
            {
                List <ProductTypeDO> result = new List <ProductTypeDO>();
                foreach (var item in db.Tbl_ProductType.Where(p => p.ParentId == parent).OrderByDescending(m => m.Sort.HasValue).ThenBy(p => p.Sort).ThenBy(p => p.Name))
                {
                    var model = new ProductTypeDO();
                    model.Id        = item.Id;
                    model.Name      = item.Name;
                    model.ParentID  = item.ParentId;
                    model.IsDisable = item.IsDisable;

                    result.Add(model);
                    foreach (var it in GetProductTypeFAC(item.Id))
                    {
                        var model1 = new ProductTypeDO();
                        model1.Id        = it.Id;
                        model1.Name      = it.Name;
                        model1.ParentID  = it.ParentID;
                        model1.IsDisable = it.IsDisable;
                        result.Add(model1);
                    }
                }
                return(result);
            }
        }
Exemple #2
0
 public JsonResult getProductType()
 {
     using (var db = new ProjectWebEntities())
     {
         List <ProductTypeDO> result = new List <ProductTypeDO>();
         foreach (var item in db.Tbl_ProductType.Where(p => p.ParentId == null))
         {
             var model = new ProductTypeDO();
             model.Id        = item.Id;
             model.Name      = item.Name;
             model.ParentID  = item.ParentId;
             model.IsDisable = item.IsDisable;
             result.Add(model);
             foreach (var it in GetProductTypeFAC(item.Id))
             {
                 var model1 = new ProductTypeDO();
                 model1.Id        = it.Id;
                 model1.Name      = it.Name;
                 model1.ParentID  = it.ParentID;
                 model1.IsDisable = it.IsDisable;
                 result.Add(model1);
             }
         }
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
 }