duhongyu il y a 5 ans
Parent
commit
9b6314dff5

+ 13 - 10
代码/TVShoppingCallCenter_ZLJ/Controllers/IndexCategory/IndexBaseController.cs

@@ -263,20 +263,23 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.IndexCategory
263 263
         public List<string> Category(int? CategoryId, int type, List<string> key)
264 264
         {
265 265
             var model = _qc_indexcategoryreposytory.GetSingle(x => x.F_CategoryId == CategoryId).Result;
266
-            if (type == 0)
266
+            if (model != null)
267 267
             {
268
-                key.Add("" + CategoryId);
269
-                if (model.F_ParentId > 0)
268
+                if (type == 0)
270 269
                 {
271
-                    key = Category((int)model.F_ParentId, 0, key);
270
+                    key.Add("" + CategoryId);
271
+                    if (model.F_ParentId > 0)
272
+                    {
273
+                        key = Category((int)model.F_ParentId, 0, key);
274
+                    }
272 275
                 }
273
-            }
274
-            else
275
-            {
276
-                key.Add(model.F_CategoryName);
277
-                if (model.F_ParentId > 0)
276
+                else
278 277
                 {
279
-                    key = Category((int)model.F_ParentId, 1, key);
278
+                    key.Add(model.F_CategoryName);
279
+                    if (model.F_ParentId > 0)
280
+                    {
281
+                        key = Category((int)model.F_ParentId, 1, key);
282
+                    }
280 283
                 }
281 284
             }
282 285
             return key;

+ 6 - 2
代码/TVShoppingCallCenter_ZLJ/Controllers/IndexCategory/IndexCategoryController.cs

@@ -203,7 +203,9 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.IndexCategory
203 203
         public List <string > Category(int? CategoryId, int type, List<string> key)
204 204
         {
205 205
             var model = _qc_indexcategoryreposytory.GetSingle(x => x.F_CategoryId == CategoryId).Result;
206
-                if (type==0)
206
+            if (model!=null )
207
+            {
208
+                if (type == 0)
207 209
                 {
208 210
                     key.Add("" + CategoryId);
209 211
                     if (model.F_ParentId > 0)
@@ -213,12 +215,14 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.IndexCategory
213 215
                 }
214 216
                 else
215 217
                 {
216
-                    key.Add( model.F_CategoryName);
218
+                    key.Add(model.F_CategoryName);
217 219
                     if (model.F_ParentId > 0)
218 220
                     {
219 221
                         key = Category((int)model.F_ParentId, 1, key);
220 222
                     }
221 223
                 }
224
+            }
225
+                
222 226
             return key;
223 227
         }
224 228