Exemple #1
0
 public FolderTree(string name, Folder parentFolder, DataFile file)
 {
     Name           = name;
     ParentFolderId = parentFolder?.Id;
     FileId         = file?.Id;
 }
        private void AddFiles(ModelBuilder modelBuilder)
        {
            var folders = new Folder[] {
                new Folder {
                    Id = 1, Permission = 0
                },
                new Folder {
                    Id = 2, Permission = 1
                },
                new Folder {
                    Id = 3, Permission = 2
                },
                new Folder {
                    Id = 4, Permission = 3
                },
                new Folder {
                    Id = 5, Permission = 4
                }
            };

            modelBuilder.Entity <Folder>().HasData(folders);

            byte[] example = Encoding.UTF8.GetBytes("This your file;)");
            var    files   = new DataFile[] {
                new DataFile {
                    Id = 1, Permission = 1, Data = example
                },
                new DataFile {
                    Id = 2, Permission = 2, Data = example
                },
                new DataFile {
                    Id = 3, Permission = 3, Data = example
                },
                new DataFile {
                    Id = 4, Permission = 4, Data = example
                }
            };

            modelBuilder.Entity <DataFile>().HasData(files);

            modelBuilder.Entity <FolderTree>().HasData(new FolderTree[] {
                new FolderTree("root", folders[0], folders[0])
                {
                    Id = 1
                },
                new FolderTree("User's folder", folders[0], folders[1])
                {
                    Id = 2
                },
                new FolderTree("Kouhai's folder", folders[0], folders[2])
                {
                    Id = 3
                },
                new FolderTree("Sempai's folder", folders[0], folders[3])
                {
                    Id = 4
                },
                new FolderTree("Master folder", folders[0], folders[4])
                {
                    Id = 5
                },
                new FolderTree("Some", folders[1], files[0])
                {
                    Id = 6
                },
                new FolderTree("Kouhai's file", folders[2], files[1])
                {
                    Id = 7
                },
                new FolderTree("Sempai's file", folders[3], files[2])
                {
                    Id = 8
                },
                new FolderTree("Master file", folders[4], files[3])
                {
                    Id = 9
                }
            });
        }