1
Vote

Category.GetTreeAsync: SubCategories have empty Category property

description

This is my fix:
public async Task<List<Category>> GetTreeAsync(bool Associative, bool Empty, string Extras, bool Heavy, int LastUpdated, string SitePassword, string ShareGroupTag)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], Associative, Callback, Empty, Extras, Heavy, LastUpdated, NickName, Pretty, SitePassword, Strict, ShareGroupTag
            var resp = await ch.ExecuteMethod<CategoryResponse>("smugmug.users.getTree", basic, "NickName", basic.NickName, "Heavy", Heavy, "Associative", Associative, "Empty", Empty, "Extras", Extras, "LastUpdated", LastUpdated, "SitePassword", SitePassword, "ShareGroupTag", ShareGroupTag);
            if (resp.stat == "ok")
            {
                var categoryList = new List<Category>();
                categoryList.AddRange(resp.Categories);

                foreach (var myCategory in categoryList)
                {
                    myCategory.basic = basic;
                    if (myCategory.Albums == null) myCategory.Albums = new List<Album>();

                    foreach (var myAlbum in myCategory.Albums)
                    {
                        myAlbum.basic = basic;
                    }
                    if (myCategory.SubCategories == null) myCategory.SubCategories = new List<SubCategory>();

                    foreach (var mySubCategory in myCategory.SubCategories)
                    {
                        mySubCategory.basic = basic;
                        mySubCategory.Category = myCategory;
                        if (mySubCategory.Albums != null)
                        {
                            foreach (var myAlbum in mySubCategory.Albums)
                            {
                                myAlbum.basic = basic;
                            }
                        }
                    }
                    
                }
 
                return categoryList;
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }

comments

alexgh wrote Mar 8, 2014 at 6:38 PM

Thanks!

I will integrate this fix!

Thanks.
Alex