public void CreateRepositoryInterface()
        {
            var template = FileHelper.GetFile(_templatePath, "RepositoryInterfaceTemplate.txt");
            var content  = template.Replace("[ENTITY_NAME]", _entity.Name);

            FileHelper.CreateFile(_repositoryInterfacePath + "\\I" + _entity.Name + "Repository.cs", content);
        }
Exemple #2
0
        public void Create()
        {
            var repositoryTemplate       = FileHelper.GetFile(_repositoryImplementationTemplatePath, "RepositoryInterfaceImplementationTemplate.txt");
            var repositoryImplementation = repositoryTemplate.Replace("[ENTITY_NAME]", _entity.Name);

            FileHelper.CreateFile(_repositoryImplementationFolderPath + $"\\{_entity.Name}Repository.cs", repositoryImplementation);
        }
        public void CreateServiceInterface()
        {
            var template = FileHelper.GetFile(_templatePath, "ServiceInterfaceTemplate.txt");
            var content  = template.Replace("[ENTITY_NAME]", _entity.Name);

            FileHelper.CreateFile(_serviceInterfacePath + "\\I" + _entity.Name + "Service.cs", content);
        }
Exemple #4
0
        public void Create()
        {
            var serviceTemplate       = FileHelper.GetFile(_serviceImplementationTemplatePath, "ServiceInterfaceImplementationTemplate.txt");
            var serviceImplementation = serviceTemplate.Replace("[ENTITY_NAME]", _entity.Name);

            FileHelper.CreateFile(_serviceImplementationFolderPath + $"\\{_entity.Name}Service.cs", serviceImplementation);
        }
        public void CreateSearchQuery()
        {
            var searchQueryTemplate   = FileHelper.GetFile(_searchQueryTemplatePath, "SearchQueryTemplate.txt");
            var propsWithoutDateTimes = _entityProperties.Where(p => p.PropertyType != typeof(DateTime) && p.PropertyType != typeof(DateTime?)).ToList();

            var properties = PropertyHelper.TransforPropertysToStatements(propsWithoutDateTimes);

            foreach (var p in _entityProperties)
            {
                if (p.PropertyType == typeof(DateTime))
                {
                    properties.Add($"public DateTime {p.Name}From" + " { get; set; }");
                    properties.Add($"public DateTime {p.Name}To" + " { get; set; }");
                }
                else if (p.PropertyType == typeof(DateTime?))
                {
                    properties.Add($"public DateTime? {p.Name}From" + " { get; set; }");
                    properties.Add($"public DateTime? {p.Name}To" + " { get; set; }");
                }
            }

            var propertiesAsString = string.Join("\n\t\t", properties);

            var searchQueryImplementation = searchQueryTemplate.Replace("[ENTITY_NAME]", _entity.Name).Replace("[PROPERTIES]", propertiesAsString);

            FileHelper.CreateFile(_searchQueryFolderPath + $"\\{_entity.Name}SearchQuery.cs", searchQueryImplementation);
        }
Exemple #6
0
        public void Create()
        {
            var controllerTemplate       = FileHelper.GetFile(_controllerTemplatePath, "ControllerTemplate.txt");
            var controllerImplementation = controllerTemplate.Replace("[ENTITY_NAME]", _entity.Name);

            FileHelper.CreateFile(_controllerImplementationFolderPath + $"\\{_entity.Name}Controller.cs", controllerImplementation);
        }
Exemple #7
0
        private void CreateDto(string dtoType)
        {
            var dtoTemplate = GetDtoTemplate($"{dtoType}DtoTemplate.txt");
            var dtoContent  = GetDtoContent(dtoTemplate, _entity.Name, _dtoProperties);
            var dtoPath     = $@"{_dtoDirectory}\{_entity.Name}{$"{dtoType}Dto.cs"}";

            FileHelper.CreateFile(dtoPath, dtoContent);
        }
        public void CreateDbContext()
        {
            var dbContextContent = GetDbContextContent();
            var dbSetName        = TextHelper.ConvertWordToPlural(_entity.Name);
            var newContent       = dbContextContent.Replace("protected override void OnConfiguring",
                                                            "public DbSet<" + _entity.Name + "> " + dbSetName + " { get; set; } \n\n\t\tprotected override void OnConfiguring");

            FileHelper.CreateFile(_dbContextPath + "\\CustomDbContext.cs", newContent);
        }
        public void Create()
        {
            var configureServiceHelper = FileHelper.GetFile(_configureServiceHelperFolderPath, "ConfigureServicesHelper.cs");
            var addService             = $"services.AddScoped<I{_entity.Name}Service, {_entity.Name}Service>();\n";
            var addRepository          = $"\t\t\tservices.AddScoped<I{_entity.Name}Repository, {_entity.Name}Repository>();\n\n";

            var newImplementation = configureServiceHelper.Replace("return services;", addService + addRepository + "\t\t\treturn services;");

            FileHelper.CreateFile(_configureServiceHelperFolderPath + $"\\ConfigureServicesHelper.cs", newImplementation);
        }