public void GetCategoryByParentID(int ParentID) { var rs = new ResponseClass(); var category = CategoryController.API_GetByParentID(ParentID); if (category.Count > 0) { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.SUCCESS); rs.Status = APIUtils.ResponseMessage.Success.ToString(); rs.Category = category; } else { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.NotFound); rs.Status = APIUtils.ResponseMessage.Error.ToString(); rs.Message = APIUtils.OBJ_DNTEXIST; } Context.Response.ContentType = "application/json"; Context.Response.Write(JsonConvert.SerializeObject(rs, Formatting.Indented)); Context.Response.Flush(); Context.Response.End(); }
public static string getParent(int parent) { List <GetOutCategory> gc = new List <GetOutCategory>(); if (parent != 0) { var parentlist = CategoryController.API_GetByParentID(parent); if (parentlist != null) { for (int i = 0; i < parentlist.Count; i++) { GetOutCategory go = new GetOutCategory(); go.ID = parentlist[i].ID; go.CategoryName = parentlist[i].CategoryName; go.CategoryLevel = parentlist[i].CategoryLevel.ToString(); gc.Add(go); } } } JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(gc)); }