mirror of https://github.com/abpframework/abp.git
Browse Source
- IBlogAppService - dtos + auto mapper configuration - IBlogRepository & ef core repository implementationpull/318/head
5 changed files with 88 additions and 8 deletions
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace Volo.Blogging.Blogs |
||||
|
{ |
||||
|
public interface IBlogAppService : IApplicationService |
||||
|
{ |
||||
|
Task<ListResultDto<BlogDto>> GetListAsync(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace Volo.Blogging.Blogs |
||||
|
{ |
||||
|
public class BlogAppService : ApplicationService, IBlogAppService |
||||
|
{ |
||||
|
private readonly IBlogRepository _blogRepository; |
||||
|
|
||||
|
public BlogAppService(IBlogRepository blogRepository) |
||||
|
{ |
||||
|
_blogRepository = blogRepository; |
||||
|
} |
||||
|
public async Task<ListResultDto<BlogDto>> GetListAsync() |
||||
|
{ |
||||
|
var blogs = await _blogRepository.GetListAsync(); |
||||
|
|
||||
|
return new ListResultDto<BlogDto>( |
||||
|
ObjectMapper.Map<List<Blog>, List<BlogDto>>(blogs) |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
|
||||
|
namespace Volo.Blogging.Blogs |
||||
|
{ |
||||
|
public interface IBlogRepository : IBasicRepository<Blog, Guid> |
||||
|
{ |
||||
|
Task<Blog> FindByShortNameAsync(string shortName); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Blogging.EntityFrameworkCore; |
||||
|
|
||||
|
namespace Volo.Blogging.Blogs |
||||
|
{ |
||||
|
public class EfCoreBlogRepository : EfCoreRepository<IBloggingDbContext, Blog, Guid>, IBlogRepository |
||||
|
{ |
||||
|
public EfCoreBlogRepository(IDbContextProvider<IBloggingDbContext> dbContextProvider) |
||||
|
: base(dbContextProvider) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public async Task<Blog> FindByShortNameAsync(string shortName) |
||||
|
{ |
||||
|
return await DbSet.FirstOrDefaultAsync(p => p.ShortName == shortName); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue