using System.Threading.Tasks; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.Guids; using Volo.Abp.PermissionManagement; using Volo.Abp.Uow; using Volo.Blogging; using Volo.Blogging.Blogs; using Volo.Blogging.Posts; namespace Company.Project.BloggingService; public class BlogServiceDataSeeder : IDataSeedContributor, ITransientDependency { private readonly IBlogRepository _blogRepository; private readonly IPostRepository _postRepository; private readonly IGuidGenerator _guidGenerator; private readonly IPermissionDataSeeder _permissionDataSeeder; public BlogServiceDataSeeder( IBlogRepository blogRepository, IGuidGenerator guidGenerator, IPostRepository postRepository, IPermissionDataSeeder permissionDataSeeder) { _blogRepository = blogRepository; _guidGenerator = guidGenerator; _postRepository = postRepository; _permissionDataSeeder = permissionDataSeeder; } [UnitOfWork] public virtual async Task SeedAsync(DataSeedContext context) { await CreateBlogPostsAsync(); await GrantAdminPermissionsAsync(); } private async Task GrantAdminPermissionsAsync() { await _permissionDataSeeder.SeedAsync( RolePermissionValueProvider.ProviderName, "admin", BloggingPermissions.GetAll() ); } private async Task CreateBlogPostsAsync() { if (await _blogRepository.GetCountAsync() > 0) { return; } var abpBlog = await _blogRepository.InsertAsync( new Blog( _guidGenerator.Create(), "ABP", "abp" ) ); await _postRepository.InsertAsync( new Post( _guidGenerator.Create(), abpBlog.Id, "Introduction to ABP vNext", "/api/blogging/files/www/100d4c0445cbf55f687339ec8e656abb.jpg", "introduction-to-abp-vnext" ) { Content = @"### Introduction For a while, we were working to design a new major version of the ASP.NET Boilerplate framework. Now, it's time to share it with the community. We are too excited and we believe that you are too. #### Naming The name of the framework remains same, except we will call it only as ""ABP"" instead of ""ASP.NET Boilerplate"". Because, the ""boilerplate"" word leads to misunderstandings and does not reflect that it is a framework (instead of some boilerplate code). We continue to use the ""ABP"" name since it's the successor of the current ASP.NET Boilerplate framework, except it's a rewrite. ### How To Start We have created a startup template. You can just create a new project from https://abp.io/Templates and start your development. For more information, visit [abp.io](https://abp.io). ### Why A Complete Rewrite? When we first introduced the ABP framework, it was 2013 (5 years ago)! There was no .Net Core & ASP.NET Core and there was no Angular2+. ASP.NET Core introduced many built-in solutions (extension libraries) for dependency injection, logging, caching, localization, configuration and so on. We wanted to depend on these new extension libraries instead of 3rd-party and custom solutions. #### Application Modularity The first goal is to provide a good infrastructure to develop application modules. We think a module as a set of application features with its own database, its own entities, services, APIs, UI pages, components and so on. #### Microservices We are designing the new ABP framework to be ready to develop microservices and communicate them to each other. ### Communication / Links * Official web site: [abp.io](https://abp.io) * Github: [github.com/abpframework](https://github.com/abpframework) * Twitter: [@abpframework](https://twitter.com/abpframework)" } ); } }