public static void ScaffoldEntities(string solutionDirectory, string srcDirectory, string testDirectory, string projectBaseName, List <Entity> entities, string dbContextName, bool addSwaggerComments, bool useSoftDelete, IFileSystem fileSystem) { foreach (var entity in entities) { // not worrying about DTOs, profiles, validators, fakers - they are all added by default EntityBuilder.CreateEntity(solutionDirectory, srcDirectory, entity, projectBaseName, fileSystem); DtoBuilder.CreateDtos(solutionDirectory, entity, projectBaseName); ValidatorBuilder.CreateValidators(solutionDirectory, srcDirectory, projectBaseName, entity); ProfileBuilder.CreateProfile(srcDirectory, entity, projectBaseName); ApiRouteModifier.AddRoutes(testDirectory, entity, projectBaseName); // api routes always added to testing by default. too much of a pain to scaffold dynamically var isProtected = entity.Features.Any(f => f.IsProtected); // <-- one more example of why it would be nice to have specific endpoints for each feature 😤 if (entity.Features.Count > 0) { ControllerBuilder.CreateController(solutionDirectory, srcDirectory, entity.Name, entity.Plural, projectBaseName, isProtected, fileSystem); } // TODO refactor to factory? foreach (var feature in entity.Features) { AddFeatureToProject(solutionDirectory, srcDirectory, testDirectory, projectBaseName, dbContextName, addSwaggerComments, feature, entity, useSoftDelete, fileSystem); } // Shared Tests FakesBuilder.CreateFakes(solutionDirectory, testDirectory, projectBaseName, entity, fileSystem); } }
public static void ScaffoldEntities(string srcDirectory, string testDirectory, string projectBaseName, List <Entity> entities, string dbContextName, bool addSwaggerComments, IFileSystem fileSystem) { foreach (var entity in entities) { // not worrying about DTOs, profiles, validators, fakers - they are all added by default EntityBuilder.CreateEntity(srcDirectory, entity, projectBaseName, fileSystem); DtoBuilder.CreateDtos(srcDirectory, entity, projectBaseName); ValidatorBuilder.CreateValidators(srcDirectory, projectBaseName, entity); ProfileBuilder.CreateProfile(srcDirectory, entity, projectBaseName); ApiRouteModifier.AddRoutes(testDirectory, entity, projectBaseName); // api routes always added to testing by default. too much of a pain to scaffold if (entity.Features.Count > 0) { ControllerBuilder.CreateController(srcDirectory, entity.Name, entity.Plural, projectBaseName); } // TODO refactor to factory? foreach (var feature in entity.Features) { AddFeatureToProject(srcDirectory, testDirectory, projectBaseName, dbContextName, addSwaggerComments, feature.Policies, feature, entity, fileSystem); } // Shared Tests FakesBuilder.CreateFakes(testDirectory, projectBaseName, entity); } }
private static void RunEntityBuilders(string srcDirectory, string testDirectory, AddEntityTemplate template, IFileSystem fileSystem, Verbosity verbosity) { //entities EntityScaffolding.ScaffoldEntities(srcDirectory, testDirectory, template.SolutionName, template.Entities, template.DbContextName, template.AddSwaggerComments, template.AuthorizationSettings.Policies, fileSystem, verbosity); //seeders & dbsets InfrastructureServiceRegistrationModifier.AddPolicies(srcDirectory, template.AuthorizationSettings.Policies, template.SolutionName); SeederModifier.AddSeeders(srcDirectory, template.Entities, template.DbContextName, template.SolutionName); DbContextModifier.AddDbSet(srcDirectory, template.Entities, template.DbContextName, template.SolutionName); ApiRouteModifier.AddRoutes(testDirectory, template.Entities, template.SolutionName); }