public List <FolderDTO> GetAllFolder(int ownerid)
 {
     return(FolderBO.GetAllFolderInfo(ownerid));
 }
 public List <FolderDTO> GetAllFolder(int parentid, int ownerid)
 {
     return(FolderBO.GetAllFolderInfo(parentid, ownerid));
 }
        public Object GenerateMetadata(int folderid, int ownerid)
        {
            var ParentFolderDTO = FolderBO.GetFolderInfoByID(folderid);
            var ChildFolderDTO  = FolderBO.GetAllFolderInfo(folderid, ownerid);

            var FileDTO = FileBO.GetAllFileInfo(folderid);


            // Generating Guid
            String fileName = Guid.NewGuid().ToString() + ".pdf";

            // Physical path of root folder
            var rootPath     = HttpContext.Current.Server.MapPath("~/Files");
            var filefullpath = Path.Combine(rootPath, fileName);

            // Making pdf file
            var writer   = new PdfWriter(filefullpath);
            var pdf      = new PdfDocument(writer);
            var document = new Document(pdf);

            document.Add(new Paragraph("Name: " + ParentFolderDTO.Name));
            document.Add(new Paragraph("Type: Folder"));
            document.Add(new Paragraph("Size: NILL"));
            if (ParentFolderDTO.ParentFolderID == 0)
            {
                document.Add(new Paragraph("Parent: ROOT"));
            }
            else
            {
                document.Add(new Paragraph("Parent: " + FolderBO.GetParentName(ParentFolderDTO.ParentFolderID)));
            }
            document.Add(new Paragraph(Environment.NewLine));

            //Child Folders info
            if (ChildFolderDTO.Any(item => item.ID != 0))
            {
                document.Add(new Paragraph(" ******* Sub Directories Information ******"));
                document.Add(new Paragraph(Environment.NewLine));
                foreach (var item in ChildFolderDTO)
                {
                    document.Add(new Paragraph("Name: " + item.Name));
                    document.Add(new Paragraph("Type: Folder"));
                    document.Add(new Paragraph("Size: NILL"));
                    document.Add(new Paragraph("Parent: " + ParentFolderDTO.Name));
                    document.Add(new Paragraph(Environment.NewLine));
                }
            }
            if (FileDTO.Any(item => item.ID != 0))
            {
                // Files information
                document.Add(new Paragraph("******* File Information ********"));
                document.Add(new Paragraph(Environment.NewLine));
                foreach (var item in FileDTO)
                {
                    document.Add(new Paragraph("Name: " + item.Name));
                    document.Add(new Paragraph("Type: " + item.FileType));
                    document.Add(new Paragraph("Size: " + (item.Size) + " KB"));
                    document.Add(new Paragraph("Parent: " + ParentFolderDTO.Name));
                    document.Add(new Paragraph(Environment.NewLine));
                }
            }
            document.Close();


            if (fileName != null)
            {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

                byte[]       file = File.ReadAllBytes(filefullpath);
                MemoryStream ms   = new MemoryStream(file);

                response.Content = new ByteArrayContent(file);
                response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");

                response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
                response.Content.Headers.ContentDisposition.FileName = fileName;
                return(response);
            }
            else
            {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotFound);
                return(response);
            }
        }