Ejemplo n.º 1
0
        private IActionResult toDetails(BookmarkEntity bookmarkEntity)
        {
            switch (bookmarkEntity.BookmarkType)
            {
            case BookmarkEntity.Type.FOLDER:
            {
                if (bookmarkEntity.ParentPath == null || bookmarkEntity.ParentPath.Equals("") || bookmarkEntity.ParentPath.Equals("Root"))
                {
                    ViewBag.DirectChild   = bookmarkEntityRepo.NumberOfDirectItems(bookmarkEntity.Name);
                    ViewBag.IndirectChild = bookmarkEntityRepo.NumberOfIndirectItems(bookmarkEntity.Name);
                }
                else
                {
                    ViewBag.DirectChild   = bookmarkEntityRepo.NumberOfDirectItems(bookmarkEntity.ParentPath + "|" + bookmarkEntity.Name);
                    ViewBag.IndirectChild = bookmarkEntityRepo.NumberOfIndirectItems(bookmarkEntity.ParentPath + "|" + bookmarkEntity.Name);
                }

                return(View("Folder/Details", bookmarkEntity));
            }

            case BookmarkEntity.Type.LINK:
            {
                return(View("Link/Details", bookmarkEntity));
            }

            case BookmarkEntity.Type.LOCATION:
            {
                return(View("Location/Details", bookmarkEntity));
            }

            case BookmarkEntity.Type.TEXTFILE:
            {
                return(View("Textfile/Details", bookmarkEntity));
            }

            default:
            {
                return(View("Details"));
            }
            }
        }
Ejemplo n.º 2
0
        private dynamic GetBookMarksTreeStringList(dynamic dynamic, int Level)
        {
            if (dynamic != null)
            {
                StringBuilder @string = new StringBuilder();
                foreach (BookMarkTreeHelperModel root in dynamic)
                {
                    string id     = "item-";
                    string parent = string.Empty;

                    if (root.ParentPath == null || root.ParentPath.Equals(""))
                    {
                        id    += root.folder;
                        parent = root.folder;
                    }
                    else
                    {
                        id    += root.ParentPath.Replace("|", "-") + "-" + root.folder;
                        parent = root.ParentPath + "|" + root.folder;
                    }

                    bool subFolder = (root.subBookmarks != null &&
                                      root.subBookmarks.Count > 0);
                    @string.Append("<a ").Append(FormatAppend("data-toggle", "collapse"))
                    .Append(FormatAppend("style", "padding-left:" + Level * 25 + "px;"))
                    .Append(FormatAppend("data-parent", "#accordian"))
                    .Append(FormatAppend("class", "list-group-item"))
                    .Append(FormatAppend("href", "#" + id)).Append(">");
                    if (subFolder)
                    {
                        //glyphicon arrow
                        @string.Append("<span ").Append(FormatAppend("class", "glyphicon glyphicon-chevron-right"))
                        .Append("></span>");
                    }
                    //glyphicon Type

                    switch (root.type)
                    {
                    case BookmarkEntity.Type.FOLDER:
                    {
                        @string.Append("<span ").Append(FormatAppend("class", "glyphicon glyphicon-folder-open")).Append("></span>");
                        break;
                    }

                    case BookmarkEntity.Type.LINK:
                    {
                        @string.Append("<span ").Append(FormatAppend("class", "glyphicon glyphicon-link")).Append("></span>");
                        break;
                    }

                    case BookmarkEntity.Type.LOCATION:
                    {
                        @string.Append("<span ").Append(FormatAppend("class", "glyphicon glyphicon-map-marker")).Append("></span>");
                        break;
                    }

                    case BookmarkEntity.Type.TEXTFILE:
                    {
                        @string.Append("<span ").Append(FormatAppend("class", "glyphicon glyphicon-file")).Append("></span>");
                        break;
                    }
                    }
                    //FOLDERNAME
                    @string.Append(root.folder);
                    var indirectFiles = bookmarkEntityRepo.NumberOfIndirectItems(parent.Replace("Root|", ""));
                    if (indirectFiles > 0)
                    {
                        //Number of indirect Folder badge
                        @string.Append("<span ").Append(FormatAppend("class", "badge badge-pill badge-secondary"))
                        .Append(">")
                        .Append("Indirect Items: ")
                        .Append(indirectFiles);
                    }
                    var directFiles = bookmarkEntityRepo.NumberOfDirectItems(parent.Replace("Root|", ""));
                    if (directFiles > 0)
                    {
                        @string.Append("</span>")
                        //Number of direct Folder badge
                        .Append("<span ").Append(FormatAppend("class", "badge badge-pill badge-primary"))
                        .Append(">")
                        .Append("Direct Items: ")
                        .Append(directFiles)
                        .Append("</span>");
                    }
                    @string.Append("</a>");
                    if (subFolder)
                    {
                        //if there exist subfolders, get there string recursively
                        @string.Append("<div ").Append(FormatAppend("id", id))
                        .Append(FormatAppend("class", "collapse list-group")).Append(">");
                        @string.Append(GetBookMarksTreeStringList(root.subBookmarks, Level + 1));
                        @string.Append("</div>");
                    }
                }
                return(@string);
            }
            else
            {
                return(null);
            }
        }