// Load ra danh sách các contact bằng IDLang public void Sel_Ext_ByCode(HttpContext context) { String jSonString = ""; string Code = context.Request.QueryString["Code"] != null && context.Request.QueryString["Code"] != "undefined" ? context.Request.QueryString["Code"] : ""; int IDLang = context.Request.QueryString["IDLang"] != null && context.Request.QueryString["IDLang"] != "undefined" ? int.Parse(context.Request.QueryString["IDLang"]) : 1; bool Disable = !String.IsNullOrEmpty(context.Request.QueryString["Disable"]) ? Convert.ToBoolean(context.Request.QueryString["Disable"]) : false; int IntroLenght = context.Request.QueryString["IntroLenght"] != null && context.Request.QueryString["IntroLenght"] != "undefined" ? int.Parse(context.Request.QueryString["IntroLenght"]) : -1; int TitleLenght = context.Request.QueryString["TitleLenght"] != null && context.Request.QueryString["TitleLenght"] != "undefined" ? int.Parse(context.Request.QueryString["TitleLenght"]) : -1; int Limit = context.Request.QueryString["Limit"] != null && context.Request.QueryString["Limit"] != "undefined" ? int.Parse(context.Request.QueryString["Limit"]) : 50; string Order = context.Request.QueryString["Order"] != null && context.Request.QueryString["Order"] != "undefined" ? context.Request.QueryString["Order"] : "CategoryLevel1_ID"; bool IsDesc = context.Request.QueryString["IsDesc"] != null && context.Request.QueryString["IsDesc"] != "undefined" ? bool.Parse(context.Request.QueryString["IsDesc"]) : true; CategoryLevel1BO aCategoryLevel1BO = new CategoryLevel1BO(); List<vw_CategoryLevel1ViewAll> obj = String.IsNullOrEmpty(context.Request.QueryString["Disable"]) ? aCategoryLevel1BO.Sel_Ext_ByCode(Code) : aCategoryLevel1BO.Sel_Ext_ByCode(Code, Disable); List<vw_CategoryLevel1ViewAll> ObjOrder = new List<vw_CategoryLevel1ViewAll>(); switch (Order) { case "CategoryLevel1_Code": if (IsDesc == false) { ObjOrder = obj.OrderBy(a => a.CategoryLevel1_Code).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_Code).ToList(); } break; case "CategoryLevel2_Code": if (IsDesc ==false) { ObjOrder = obj.OrderBy(a => a.CategoryLevel2_Code).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CategoryLevel2_Code).ToList(); } break; case "CountContentDisable": if (IsDesc ==false) { ObjOrder = obj.OrderBy(a => a.CountContentDisable).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CountContentDisable).ToList(); } break; case "CountContentEnable": if (IsDesc == false) { ObjOrder = obj.OrderBy(a => a.CountContentEnable).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CountContentEnable).ToList(); } break; case "CountContent": if (IsDesc == false) { ObjOrder = obj.OrderBy(a => a.CountContent).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CountContent).ToList(); } break; case "CategoryLevel2_Status": if (IsDesc == false) { ObjOrder = obj.OrderBy(a => a.CategoryLevel2_Status).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CategoryLevel2_Status).ToList(); } break; case "CategoryLevel2_ID": if (IsDesc == false) { ObjOrder = obj.OrderBy(a => a.CategoryLevel2_ID).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CategoryLevel2_ID).ToList(); } break; case "CategoryLevel1_ViewCount": if (IsDesc == false) { ObjOrder = obj.OrderBy(a => a.CategoryLevel1_ViewCount).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_ViewCount).ToList(); } break; case "CategoryLevel1_Type": if (IsDesc == false) { ObjOrder = obj.OrderBy(a => a.CategoryLevel1_Type).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_Type).ToList(); } break; case "CategoryLevel1_Status": if (IsDesc == false) { ObjOrder = obj.OrderBy(a => a.CategoryLevel1_Status).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_Status).ToList(); } break; case "CategoryLevel1_ID": if (IsDesc == false) { ObjOrder = obj.OrderBy(a => a.CategoryLevel1_ID).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_ID).ToList(); } break; case "CategoryLevel1_CategoryLevel2_Disable": if (IsDesc == false) { ObjOrder = obj.OrderBy(a => a.CategoryLevel1_CategoryLevel2_Disable).ToList(); } else { ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_CategoryLevel2_Disable).ToList(); } break; default: ObjOrder = obj; break; } for (int i = 0; i < ObjOrder.Count; i++) { if ((TitleLenght > -1) & (ObjOrder[i].CategoryLevel1_CategoryNameLevel1.Length > TitleLenght)) { ObjOrder[i].CategoryLevel1_CategoryNameLevel1 = ObjOrder[i].CategoryLevel1_CategoryNameLevel1.Substring(0, TitleLenght - 1); } if ((IntroLenght > -1) & (ObjOrder[i].CategoryLevel1_Info.Length > IntroLenght)) { ObjOrder[i].CategoryLevel1_Info = ObjOrder[i].CategoryLevel1_Info.Substring(0, IntroLenght - 1); } } List<vw_CategoryLevel1ViewAll> ObjOrderLimit = new List<vw_CategoryLevel1ViewAll>(); if ((Limit > -1) & (ObjOrder.Count > Limit)) { ObjOrderLimit = ObjOrder.GetRange(0, Limit).ToList(); _converter.DateTimeFormat = "dd/MM/yyyy"; jSonString = JsonConvert.SerializeObject(ObjOrderLimit, _converter); } else { if (ObjOrder != null) { _converter.DateTimeFormat = "dd/MM/yyyy"; jSonString = JsonConvert.SerializeObject(ObjOrder, _converter); } } jSonString = "{\"CategoryLevel1\":" + jSonString + "}"; context.Response.Write(jSonString); }