Skip to content

Commit

Permalink
Refactoring base classes in commands and queries
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerlrhodes committed Apr 23, 2017
1 parent ac0b404 commit 42da7b6
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@

namespace Bagombo.Data.Command.EFCoreCommandHandlers
{
public class AddFeatureCommandEFCommandHandler : ICommandHandlerAsync<AddFeatureCommand>
public class AddFeatureCommandEFCommandHandler : EFCHBase, ICommandHandlerAsync<AddFeatureCommand>
{
private BlogDbContext _context;

public AddFeatureCommandEFCommandHandler(BlogDbContext context)
public AddFeatureCommandEFCommandHandler(BlogDbContext context) : base(context)
{
_context = context;
}

public async Task<CommandResult<AddFeatureCommand>> ExecuteAsync(AddFeatureCommand command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

namespace Bagombo.Data.Query.EFCoreQueryHandlers
{
public class GetAllPostsByCategoryViewModelEFQH : IQueryHandlerAsync<GetAllPostsByCategoryViewModelQuery, AllPostsViewModel>
public class GetAllPostsByCategoryViewModelEFQH : EFQHBase, IQueryHandlerAsync<GetAllPostsByCategoryViewModelQuery, AllPostsViewModel>
{
private BlogDbContext _context;

public GetAllPostsByCategoryViewModelEFQH(BlogDbContext context)
public GetAllPostsByCategoryViewModelEFQH(BlogDbContext context) : base(context)
{
_context = context;
}

public async Task<AllPostsViewModel> HandleAsync(GetAllPostsByCategoryViewModelQuery query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

namespace Bagombo.Data.Query.EFCoreQueryHandlers
{
public class GetAllPostsByDateViewModelEFQH : IQueryHandlerAsync<GetAllPostsByDateViewModelQuery, AllPostsViewModel>
public class GetAllPostsByDateViewModelEFQH : EFQHBase, IQueryHandlerAsync<GetAllPostsByDateViewModelQuery, AllPostsViewModel>
{
BlogDbContext _context;

public GetAllPostsByDateViewModelEFQH(BlogDbContext context)
public GetAllPostsByDateViewModelEFQH(BlogDbContext context) : base(context)
{
_context = context;
}

public async Task<AllPostsViewModel> HandleAsync(GetAllPostsByDateViewModelQuery query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

namespace Bagombo.Data.Query.EFCoreQueryHandlers
{
public class GetBlogPostByIdViewModelEFQH : IQueryHandlerAsync<GetBlogPostByIdViewModelQuery, BlogPostViewModel>
public class GetBlogPostByIdViewModelEFQH : EFQHBase, IQueryHandlerAsync<GetBlogPostByIdViewModelQuery, BlogPostViewModel>
{
BlogDbContext _context;

public GetBlogPostByIdViewModelEFQH(BlogDbContext context)
public GetBlogPostByIdViewModelEFQH(BlogDbContext context) : base(context)
{
_context = context;
}

public async Task<BlogPostViewModel> HandleAsync(GetBlogPostByIdViewModelQuery query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

namespace Bagombo.Data.Query.EFCoreQueryHandlers
{
public class GetCategoryPostsByCategoryViewModelEFQH : IQueryHandlerAsync<GetCategoryPostsByCategoryViewModelQuery, CategoryPostsViewModel>
public class GetCategoryPostsByCategoryViewModelEFQH : EFQHBase, IQueryHandlerAsync<GetCategoryPostsByCategoryViewModelQuery, CategoryPostsViewModel>
{
private BlogDbContext _context;

public GetCategoryPostsByCategoryViewModelEFQH(BlogDbContext context)
public GetCategoryPostsByCategoryViewModelEFQH(BlogDbContext context) : base(context)
{
_context = context;
}

public async Task<CategoryPostsViewModel> HandleAsync(GetCategoryPostsByCategoryViewModelQuery query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@

namespace Bagombo.Data.Query.EFCoreQueryHandlers
{
public class GetFeatureByIdEFQH : IQueryHandlerAsync<GetFeatureByIdQuery, Feature>
public class GetFeatureByIdEFQH : EFQHBase, IQueryHandlerAsync<GetFeatureByIdQuery, Feature>
{
private BlogDbContext _context;

public GetFeatureByIdEFQH(BlogDbContext context)
public GetFeatureByIdEFQH(BlogDbContext context) : base(context)
{
_context = context;
}

public async Task<Feature> HandleAsync(GetFeatureByIdQuery query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

namespace Bagombo.Data.Query.EFCoreQueryHandlers
{
class GetFeaturePostsByFeatureViewModelEFQH : IQueryHandlerAsync<GetFeaturePostsByFeatureViewModelQuery, FeaturePostsViewModel>
class GetFeaturePostsByFeatureViewModelEFQH : EFQHBase, IQueryHandlerAsync<GetFeaturePostsByFeatureViewModelQuery, FeaturePostsViewModel>
{
BlogDbContext _context;

public GetFeaturePostsByFeatureViewModelEFQH(BlogDbContext context)
public GetFeaturePostsByFeatureViewModelEFQH(BlogDbContext context) : base(context)
{
_context = context;
}

public async Task<FeaturePostsViewModel> HandleAsync(GetFeaturePostsByFeatureViewModelQuery query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

namespace Bagombo.Data.Query.EFCoreQueryHandlers
{
public class GetFeaturesViewModelEFQH : IQueryHandlerAsync<GetFeaturesViewModelQuery, FeaturesViewModel>
public class GetFeaturesViewModelEFQH : EFQHBase, IQueryHandlerAsync<GetFeaturesViewModelQuery, FeaturesViewModel>
{
BlogDbContext _context;

public GetFeaturesViewModelEFQH(BlogDbContext context)
public GetFeaturesViewModelEFQH(BlogDbContext context) : base(context)
{
_context = context;
}

public async Task<FeaturesViewModel> HandleAsync(GetFeaturesViewModelQuery query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

namespace Bagombo.Data.Query.EFCoreQueryHandlers
{
public class GetRecentBlogPostsEFQH : IQueryHandlerAsync<GetRecentBlogPostsQuery, IList<BlogPost>>
public class GetRecentBlogPostsEFQH : EFQHBase, IQueryHandlerAsync<GetRecentBlogPostsQuery, IList<BlogPost>>
{
private BlogDbContext _context;

public GetRecentBlogPostsEFQH(BlogDbContext context)
public GetRecentBlogPostsEFQH(BlogDbContext context) : base(context)
{
_context = context;
}

public async Task<IList<BlogPost>> HandleAsync(GetRecentBlogPostsQuery query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@

namespace Bagombo.Data.Query.EFCoreQueryHandlers
{
public class GetSearchResultBlogPostsBySearchTextViewModelEFQH : IQueryHandlerAsync<GetSearchResultBlogPostsBySearchTextViewModelQuery, IList<SearchResultBlogPostViewModel>>
public class GetSearchResultBlogPostsBySearchTextViewModelEFQH : EFQHBase, IQueryHandlerAsync<GetSearchResultBlogPostsBySearchTextViewModelQuery, IList<SearchResultBlogPostViewModel>>
{
BlogDbContext _context;

public GetSearchResultBlogPostsBySearchTextViewModelEFQH(BlogDbContext context)
public GetSearchResultBlogPostsBySearchTextViewModelEFQH(BlogDbContext context) : base(context)
{
_context = context;
}

public async Task<IList<SearchResultBlogPostViewModel>> HandleAsync(GetSearchResultBlogPostsBySearchTextViewModelQuery query)
Expand Down
10 changes: 5 additions & 5 deletions src/Bagombo/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public class AdminController : Controller
{
private ICommandProcessorAsync _cp;
private IQueryProcessorAsync _qpa;
UserManager<ApplicationUser> _userManager;
SignInManager<ApplicationUser> _signInManager;
IPasswordHasher<ApplicationUser> _passwordHasher;
IUserValidator<ApplicationUser> _userValidator;
IPasswordValidator<ApplicationUser> _passwordValidator;
private UserManager<ApplicationUser> _userManager;
private SignInManager<ApplicationUser> _signInManager;
private IPasswordHasher<ApplicationUser> _passwordHasher;
private IUserValidator<ApplicationUser> _userValidator;
private IPasswordValidator<ApplicationUser> _passwordValidator;

public AdminController(ICommandProcessorAsync cp,
IQueryProcessorAsync qpa,
Expand Down
6 changes: 3 additions & 3 deletions src/Bagombo/Controllers/AuthorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ namespace Bagombo.Controllers
[Authorize(Roles = "Authors")]
public class AuthorController : Controller
{
IQueryProcessorAsync _qpa;
ICommandProcessorAsync _cp;
UserManager<ApplicationUser> _userManager;
private IQueryProcessorAsync _qpa;
private ICommandProcessorAsync _cp;
private UserManager<ApplicationUser> _userManager;

public AuthorController(IQueryProcessorAsync qpa,
ICommandProcessorAsync cp,
Expand Down

0 comments on commit 42da7b6

Please sign in to comment.