Browse Source

Refactoring code for clean architecture

Feature
Safet Purkovic 4 years ago
parent
commit
98c8a0db35
28 changed files with 69 additions and 63 deletions
  1. BIN
      BlackRock.Reporting.API/BlackRock.db-shm
  2. BIN
      BlackRock.Reporting.API/BlackRock.db-wal
  3. 1
    1
      BlackRock.Reporting.API/Controllers/Model/ErrorResponse.cs
  4. 5
    3
      BlackRock.Reporting.API/Controllers/UsersController.cs
  5. 0
    3
      BlackRock.Reporting.API/Core/IRepository.cs
  6. 3
    4
      BlackRock.Reporting.API/Core/IUsersRepository.cs
  7. 1
    1
      BlackRock.Reporting.API/Core/Models/IBaseEntity.cs
  8. 1
    2
      BlackRock.Reporting.API/Core/Models/IPaggingAndFiltering.cs
  9. 7
    0
      BlackRock.Reporting.API/Core/Models/IUserPaggingAndFiltering.cs
  10. 18
    0
      BlackRock.Reporting.API/Core/Models/PaggingAndFiltering.cs
  11. 2
    3
      BlackRock.Reporting.API/Core/Models/PaggingCollection.cs
  12. 1
    1
      BlackRock.Reporting.API/Core/Models/User.cs
  13. 1
    2
      BlackRock.Reporting.API/Extensions/IQueryableExtensions.cs
  14. 2
    2
      BlackRock.Reporting.API/Mediator/Commands/CreateUsersCommand.cs
  15. 1
    2
      BlackRock.Reporting.API/Mediator/Commands/DeleteUsersCommand.cs
  16. 3
    3
      BlackRock.Reporting.API/Mediator/Commands/UpdateAllUsersCommand.cs
  17. 4
    4
      BlackRock.Reporting.API/Mediator/Commands/UpdateEmailUsersCommand.cs
  18. 1
    1
      BlackRock.Reporting.API/Mediator/Dto/UserDto.cs
  19. 0
    11
      BlackRock.Reporting.API/Mediator/Model/PaggingAndFiltering.cs
  20. 1
    1
      BlackRock.Reporting.API/Mediator/Model/Result.cs
  21. 4
    4
      BlackRock.Reporting.API/Mediator/Queries/GetAllUsersQuery.cs
  22. 4
    4
      BlackRock.Reporting.API/Mediator/Queries/GetUsersQuery.cs
  23. 1
    1
      BlackRock.Reporting.API/Persistence/BRDbContext.cs
  24. 0
    2
      BlackRock.Reporting.API/Persistence/Repository.cs
  25. 4
    5
      BlackRock.Reporting.API/Persistence/UsersRepository.cs
  26. 1
    2
      BlackRock.Reporting.API/Profiles/Profiler.cs
  27. 1
    1
      BlackRock.Reporting.API/Program.cs
  28. 2
    0
      BlackRock.Reporting.API/obj/staticwebassets.pack.sentinel

BIN
BlackRock.Reporting.API/BlackRock.db-shm View File


BIN
BlackRock.Reporting.API/BlackRock.db-wal View File


BlackRock.Reporting.API/Mediator/Model/ErrorResponse.cs → BlackRock.Reporting.API/Controllers/Model/ErrorResponse.cs View File

using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding;


namespace BlackRock.Reporting.API.Mediator.Model
namespace BlackRock.Reporting.API.Controllers.Model
{ {
public class ErrorResponse public class ErrorResponse
{ {

+ 5
- 3
BlackRock.Reporting.API/Controllers/UsersController.cs View File

using BlackRock.Reporting.API.Mediator;
using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Controllers.Model;
using BlackRock.Reporting.API.Mediator.Commands;
using BlackRock.Reporting.API.Mediator.Queries;
using MediatR; using MediatR;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using BlackRock.Reporting.API.Mediator.Model;


namespace BlackRock.Reporting.API.Controllers namespace BlackRock.Reporting.API.Controllers
{ {
[Route("api/users")]
//[Route("api/users")]
public class UsersController : Controller public class UsersController : Controller
{ {
private readonly IMediator mediator; private readonly IMediator mediator;

+ 0
- 3
BlackRock.Reporting.API/Core/IRepository.cs View File

using System.Linq.Expressions;
using BlackRock.Reporting.API.Core.Models; using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Persistence;


namespace BlackRock.Reporting.API.Core namespace BlackRock.Reporting.API.Core
{ {

+ 3
- 4
BlackRock.Reporting.API/Core/IUsersRepository.cs View File

using BlackRock.Reporting.API.Mediator;
using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Core.Models;


namespace BlackRock.Reporting.API.Core namespace BlackRock.Reporting.API.Core
{ {
public interface IUsersRepository : IRepository<User> public interface IUsersRepository : IRepository<User>
{ {
void UpdateEmail(User user,string email); void UpdateEmail(User user,string email);
Task<PaggingCollection<User>> GetAllByFilter(PaggingAndFiltering queryObj);
Task<PaggingCollection<User>> GetAllByFilter(UserPaggingAndFiltering queryObj);
} }
} }

BlackRock.Reporting.API/Models/IBaseEntity.cs → BlackRock.Reporting.API/Core/Models/IBaseEntity.cs View File

namespace BlackRock.Reporting.API.Models
namespace BlackRock.Reporting.API.Core.Models
{ {
public interface IBaseEntity public interface IBaseEntity
{ {

BlackRock.Reporting.API/Mediator/Model/IPaggingAndFiltering.cs → BlackRock.Reporting.API/Core/Models/IPaggingAndFiltering.cs View File

namespace BlackRock.Reporting.API.Mediator.Model
namespace BlackRock.Reporting.API.Core.Models
{ {
public interface IPaggingAndFiltering public interface IPaggingAndFiltering
{ {
string EmailDomain {get;set;}
string SortBy { get; set; } string SortBy { get; set; }
bool IsSortAscending { get; set; } bool IsSortAscending { get; set; }
int Page { get; set; } int Page { get; set; }

+ 7
- 0
BlackRock.Reporting.API/Core/Models/IUserPaggingAndFiltering.cs View File

namespace BlackRock.Reporting.API.Core.Models
{
public interface IUserPaggingAndFiltering : IPaggingAndFiltering
{
string EmailDomain {get;set;}
}
}

+ 18
- 0
BlackRock.Reporting.API/Core/Models/PaggingAndFiltering.cs View File

namespace BlackRock.Reporting.API.Core.Models
{
public class UserPaggingAndFiltering : IUserPaggingAndFiltering
{
public string? EmailDomain { get ; set ; }
public string? SortBy { get ; set ; }
public bool IsSortAscending { get ; set ; }
public int Page { get ; set ; }
public int PageSize { get ; set ; }
}
public class PaggingAndFiltering : IPaggingAndFiltering
{
public string? SortBy {get;set;}
public bool IsSortAscending {get;set;}
public int Page {get;set;}
public int PageSize {get;set;}
}
}

BlackRock.Reporting.API/Mediator/Model/PaggingCollection.cs → BlackRock.Reporting.API/Core/Models/PaggingCollection.cs View File

using System.Collections.ObjectModel; using System.Collections.ObjectModel;


namespace BlackRock.Reporting.API.Mediator.Model
namespace BlackRock.Reporting.API.Core.Models
{ {
public class PaggingCollection<T> : Collection<T>, IPaggingAndFiltering where T : class public class PaggingCollection<T> : Collection<T>, IPaggingAndFiltering where T : class
{ {
public string SortBy {set;get;}
public string? SortBy {set;get;}
public bool IsSortAscending {set;get;} public bool IsSortAscending {set;get;}
public int Page {set;get;} public int Page {set;get;}
public int PageSize {set;get;} public int PageSize {set;get;}
public string EmailDomain {get;set;}
} }
} }

BlackRock.Reporting.API/Models/User.cs → BlackRock.Reporting.API/Core/Models/User.cs View File

using BlackRock.Reporting.API.Core.Models; using BlackRock.Reporting.API.Core.Models;


namespace BlackRock.Reporting.API.Models
namespace BlackRock.Reporting.API.Core.Models
{ {
public class User : IBaseEntity public class User : IBaseEntity
{ {

+ 1
- 2
BlackRock.Reporting.API/Extensions/IQueryableExtensions.cs View File

using System.Linq.Expressions; using System.Linq.Expressions;
using BlackRock.Reporting.API.Mediator;
using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Core.Models;


namespace BlackRock.Reporting.API.Extensions namespace BlackRock.Reporting.API.Extensions
{ {

BlackRock.Reporting.API/Mediator/CreateUsersCommand.cs → BlackRock.Reporting.API/Mediator/Commands/CreateUsersCommand.cs View File

using AutoMapper; using AutoMapper;
using BlackRock.Reporting.API.Core; using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Mediator.Model; using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using MediatR; using MediatR;


namespace BlackRock.Reporting.API.Mediator
namespace BlackRock.Reporting.API.Mediator.Commands
{ {
public class CreateUsersCommand : UserCommand, IRequest<Result<int>> public class CreateUsersCommand : UserCommand, IRequest<Result<int>>
{ {

BlackRock.Reporting.API/Mediator/DeleteUsersCommand.cs → BlackRock.Reporting.API/Mediator/Commands/DeleteUsersCommand.cs View File

using AutoMapper; using AutoMapper;
using BlackRock.Reporting.API.Core; using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Mediator.Model; using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using MediatR; using MediatR;


namespace BlackRock.Reporting.API.Mediator
namespace BlackRock.Reporting.API.Mediator.Commands
{ {
public class DeleteUsersCommand : UserQuery, IRequest<Result<int>> public class DeleteUsersCommand : UserQuery, IRequest<Result<int>>
{ {

BlackRock.Reporting.API/Mediator/UpdateAllUsersCommand.cs → BlackRock.Reporting.API/Mediator/Commands/UpdateAllUsersCommand.cs View File

using AutoMapper; using AutoMapper;
using BlackRock.Reporting.API.Controllers.Dto;
using BlackRock.Reporting.API.Core; using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Mediator.Dto;
using BlackRock.Reporting.API.Mediator.Model; using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using MediatR; using MediatR;


namespace BlackRock.Reporting.API.Mediator
namespace BlackRock.Reporting.API.Mediator.Commands
{ {
public class UpdateAllUsersCommand : IRequest<Result<UserDto>> public class UpdateAllUsersCommand : IRequest<Result<UserDto>>
{ {

BlackRock.Reporting.API/Mediator/UpdateEmailUsersCommand.cs → BlackRock.Reporting.API/Mediator/Commands/UpdateEmailUsersCommand.cs View File

using AutoMapper; using AutoMapper;
using BlackRock.Reporting.API.Controllers.Dto;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Mediator.Dto;
using BlackRock.Reporting.API.Mediator.Model; using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using MediatR; using MediatR;


namespace BlackRock.Reporting.API.Mediator
namespace BlackRock.Reporting.API.Mediator.Commands
{ {
public class UpdateEmailUsersCommand : IRequest<Result<UserDto>> public class UpdateEmailUsersCommand : IRequest<Result<UserDto>>
{ {

BlackRock.Reporting.API/Controllers/Dto/UserDto.cs → BlackRock.Reporting.API/Mediator/Dto/UserDto.cs View File

namespace BlackRock.Reporting.API.Controllers.Dto
namespace BlackRock.Reporting.API.Mediator.Dto
{ {
public class UserDto public class UserDto
{ {

+ 0
- 11
BlackRock.Reporting.API/Mediator/Model/PaggingAndFiltering.cs View File

namespace BlackRock.Reporting.API.Mediator.Model
{
public class PaggingAndFiltering : IPaggingAndFiltering
{
public string EmailDomain { get; set; }
public string SortBy {get;set;}
public bool IsSortAscending {get;set;}
public int Page {get;set;}
public int PageSize {get;set;}
}
}

BlackRock.Reporting.API/Models/Result.cs → BlackRock.Reporting.API/Mediator/Model/Result.cs View File

namespace BlackRock.Reporting.API.Models
namespace BlackRock.Reporting.API.Mediator.Model
{ {
public class Result<TData> public class Result<TData>
{ {

BlackRock.Reporting.API/Mediator/GetAllUsersQuery.cs → BlackRock.Reporting.API/Mediator/Queries/GetAllUsersQuery.cs View File

using AutoMapper; using AutoMapper;
using BlackRock.Reporting.API.Controllers.Dto;
using BlackRock.Reporting.API.Core; using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Mediator.Model; using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Mediator.Dto;
using MediatR; using MediatR;


namespace BlackRock.Reporting.API.Mediator
namespace BlackRock.Reporting.API.Mediator.Queries
{ {
public class GetAllUsersQuery : PaggingAndFiltering, IRequest<Result<PaggingCollection<UserDto>>>
public class GetAllUsersQuery : UserPaggingAndFiltering, IRequest<Result<PaggingCollection<UserDto>>>
{ {
} }



BlackRock.Reporting.API/Mediator/GetUsersQuery.cs → BlackRock.Reporting.API/Mediator/Queries/GetUsersQuery.cs View File

using AutoMapper; using AutoMapper;
using BlackRock.Reporting.API.Controllers.Dto;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Mediator.Dto;
using BlackRock.Reporting.API.Mediator.Model; using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using MediatR; using MediatR;


namespace BlackRock.Reporting.API.Mediator
namespace BlackRock.Reporting.API.Mediator.Queries
{ {
public class GetUsersQuery : UserQuery, IRequest<Result<UserDto>> public class GetUsersQuery : UserQuery, IRequest<Result<UserDto>>
{ {

+ 1
- 1
BlackRock.Reporting.API/Persistence/BRDbContext.cs View File

using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Core.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;


namespace BlackRock.Reporting.API.Persistence namespace BlackRock.Reporting.API.Persistence

+ 0
- 2
BlackRock.Reporting.API/Persistence/Repository.cs View File

using System.Linq.Expressions;
using BlackRock.Reporting.API.Core; using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models; using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;


namespace BlackRock.Reporting.API.Persistence namespace BlackRock.Reporting.API.Persistence

+ 4
- 5
BlackRock.Reporting.API/Persistence/UsersRepository.cs View File

using System.Linq.Expressions; using System.Linq.Expressions;
using BlackRock.Reporting.API.Core; using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Extensions; using BlackRock.Reporting.API.Extensions;
using BlackRock.Reporting.API.Mediator;
using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Core.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;


namespace BlackRock.Reporting.API.Persistence namespace BlackRock.Reporting.API.Persistence
{ {
this.context = context; this.context = context;
} }
public async Task<PaggingCollection<User>> GetAllByFilter(PaggingAndFiltering queryObj)
public async Task<PaggingCollection<User>> GetAllByFilter(UserPaggingAndFiltering queryObj)
{ {
var result = new PaggingCollection<User>(); var result = new PaggingCollection<User>();




query = query.ApplyOrdering(queryObj, columnsMap); query = query.ApplyOrdering(queryObj, columnsMap);


// pagging
query = query.ApplyPagging(queryObj); query = query.ApplyPagging(queryObj);

foreach (var item in query) foreach (var item in query)
{ {
result.Add(item); result.Add(item);
} }
return result; return result;


// pagging
} }
public void UpdateEmail(User user, string email) public void UpdateEmail(User user, string email)
{ {

+ 1
- 2
BlackRock.Reporting.API/Profiles/Profiler.cs View File

using AutoMapper; using AutoMapper;
using PuppeteerSharp; using PuppeteerSharp;
using BlackRock.Reporting.API.Core.Models; using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Mediator.Model; using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Controllers.Dto;
using BlackRock.Reporting.API.Mediator.Dto;


namespace BlackRock.Reporting.API.Profiles namespace BlackRock.Reporting.API.Profiles
{ {

+ 1
- 1
BlackRock.Reporting.API/Program.cs View File

using BlackRock.Reporting.API.Core; using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Persistence; using BlackRock.Reporting.API.Persistence;
using BlackRock.Reporting.API.Profiles; using BlackRock.Reporting.API.Profiles;
using MediatR; using MediatR;
//config.UseSqlServer(builder.Configuration.GetConnectionString("Default"))); //config.UseSqlServer(builder.Configuration.GetConnectionString("Default")));
config.UseSqlite("Data source=BlackRock.db")); config.UseSqlite("Data source=BlackRock.db"));
builder.Services.AddScoped<IGenerator, PdfGenerator>(); builder.Services.AddScoped<IGenerator, PdfGenerator>();
builder.Services.AddScoped(typeof(IRepository < > ), typeof(Repository < > ));
builder.Services.AddScoped<IUsersRepository,UsersRepository>(); builder.Services.AddScoped<IUsersRepository,UsersRepository>();
builder.Services.AddScoped<IUnitOfWork,UnitOfWork>(); builder.Services.AddScoped<IUnitOfWork,UnitOfWork>();
builder.Services.AddCors(); builder.Services.AddCors();

+ 2
- 0
BlackRock.Reporting.API/obj/staticwebassets.pack.sentinel View File

2.0 2.0
2.0 2.0
2.0 2.0
2.0
2.0

Loading…
Cancel
Save