예제 #1
0
        public static webModels.GetPagesResult ToWebModel(this IEnumerable <coreModels.Page> pages)
        {
            var retVal = new webModels.GetPagesResult();

            pages = pages.ToArray();

            var folders = pages.Where(i => i.Id.Split('/').Length > 1).Select(i => i.Id.Split('/')[0]).Distinct().ToList();

            if (!folders.Any(f => f.Equals("pages")))
            {
                folders.Add("pages");
            }
            if (!folders.Any(f => f.Equals("includes")))
            {
                folders.Add("includes");
            }

            foreach (var folder in folders)
            {
                var pageFolder = new webModels.PageFolder
                {
                    FolderName = folder
                };

                var addedPages = pages.Select(i => i.ToWebModel()).Where(i => i.Id.StartsWith(string.Format("{0}/", folder)));

                foreach (var page in addedPages)
                {
                    var steps = page.Name.Split('/');
                    if (steps.Length > 1)
                    {
                        steps = steps.Skip(1).ToArray();
                    }
                    page.Name = string.Join("/", steps);

                    pageFolder.Pages.Add(page);
                }

                retVal.Folders.Add(pageFolder);
            }

            var files = pages.Where(i => i.Id.Split('/').Length == 1);

            foreach (var file in files)
            {
                var addedFile = file.ToWebModel();

                var steps = addedFile.Name.Split('/');
                if (steps.Length > 1)
                {
                    steps = steps.Skip(1).ToArray();
                }
                addedFile.Name = string.Join("/", steps);

                retVal.Pages.Add(addedFile);
            }

            return(retVal);
        }
예제 #2
0
		public static webModels.GetPagesResult ToWebModel(this IEnumerable<coreModels.Page> pages)
		{
			var retVal = new webModels.GetPagesResult();

			pages = pages.ToArray();

			var folders = pages.Where(i => i.Id.Split('/').Length > 1).Select(i => i.Id.Split('/')[0]).Distinct().ToList();
			if (!folders.Any(f=> f.Equals("pages")))
			{
				folders.Add("pages");
			}
			if (!folders.Any(f => f.Equals("includes")))
			{
				folders.Add("includes");
			}

			foreach (var folder in folders)
			{
				var pageFolder = new webModels.PageFolder
				{
					FolderName = folder
				};

				var addedPages = pages.Select(i => i.ToWebModel()).Where(i => i.Id.StartsWith(string.Format("{0}/", folder)));

				foreach (var page in addedPages)
				{
					var steps = page.Name.Split('/');
					if (steps.Length > 1)
					{
						steps = steps.Skip(1).ToArray();
					}
					page.Name = string.Join("/", steps);

					pageFolder.Pages.Add(page);
				}

				retVal.Folders.Add(pageFolder);
			}

			var files = pages.Where(i => i.Id.Split('/').Length == 1);

			foreach (var file in files)
			{
				var addedFile = file.ToWebModel();

				var steps = addedFile.Name.Split('/');
				if (steps.Length > 1)
				{
					steps = steps.Skip(1).ToArray();
				}
				addedFile.Name = string.Join("/", steps);

				retVal.Pages.Add(addedFile);
			}

			return retVal;
		}
예제 #3
0
 private GetPagesResult InnerGetPages(string storeId)
 {
     var retVal = new GetPagesResult();
     var result = _contentStorageProvider.Search("/Pages/" + storeId, null);
     foreach (var folder in result.Folders)
     {
         var pageFolder = LoadFolderRecursive(folder, folder.Name);
         retVal.Folders.Add(pageFolder);
     }
     foreach (var item in result.Items)
     {
         var page = item.ToPageWebModel();
         page.Id = item.FileName;
         retVal.Pages.Add(page);
     }
     return retVal;
 }