예제 #1
0
        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();
        }
예제 #2
0
        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));
        }