AdditionalWidgets.AdditionalWidgetsController.GetSetupModelFromInclude C# (CSharp) Method

GetSetupModelFromInclude() private method

private GetSetupModelFromInclude ( AdditionalWidgetsIncludes include ) : AdditionalWidgetsModels.RecentPostsForCategoryWidgetSetupConfigModel
include AdditionalWidgetsIncludes
return AdditionalWidgetsModels.RecentPostsForCategoryWidgetSetupConfigModel
        private AdditionalWidgetsModels.RecentPostsForCategoryWidgetSetupConfigModel GetSetupModelFromInclude(AdditionalWidgetsIncludes.RecentPostsForCategoryInclude include)
        {
            var model = new AdditionalWidgetsModels.RecentPostsForCategoryWidgetSetupConfigModel();
            if (include != null && include.HasCategory)
            {
                model.Category = include.Category;
                model.Collection = include.Collection;
                model.Count = include.Count;
            }

            /*
            var collectionCategories = new List<AdditionalWidgetsModels.CollectionsCategories>();
            var collections = GetCollections();
            collections.ToList().ForEach(coll =>
                {
                    var cats = GetCategories(AtomPubService.GetCollectionFeed(coll.Id, 0));
                    if (cats.Any())
                    {
                        collectionCategories.Add(new AdditionalWidgetsModels.CollectionsCategories
                        {
                            Collection = coll.Id.ToString(),
                            Categories = cats.Select(x => new SelectListItem
                                                {
                                                    Text = string.IsNullOrEmpty(x.Label) ? x.Term : x.Label,
                                                    Value = x.Term,
                                                    Selected = x.Term == model.Category && model.Collection == coll.Id.ToString()
                                                }).ToArray()
                        });
                    }
                });
            model.Collections = collections.Where(x =>
                collectionCategories.Any(p => p.Collection == x.Id.ToString()))
                .Select(o => new SelectListItem { Text = o.Title.Text, Value = o.Id.ToString() }).ToArray();
            model.CollectionCategories = collectionCategories;
            */

            var collections = GetCollections().Where(x => x.AllCategories.Any()).ToArray();

            model.Collections = collections.Select(o => new SelectListItem { Text = o.Title.Text, Value = o.Id.ToString() }).ToArray();
            model.CollectionCategories = collections.Select((c) =>
                {
                    return
                        new AdditionalWidgetsModels.CollectionsCategories
                        {
                            Collection = c.Id.ToString(),
                            Categories = c.AllCategories.Select(x => new SelectListItem
                                                {
                                                    Text = string.IsNullOrEmpty(x.Label) ? x.Term : x.Label,
                                                    Value = x.Term,
                                                    Selected = x.Term == model.Category && model.Collection == c.Id.ToString()
                                                }).ToArray()
                        };
                });

            return model;
        }