Selaa lähdekoodia

Refactoring code for clean architecture

Feature
Safet Purkovic 4 vuotta sitten
vanhempi
commit
98c8a0db35
28 muutettua tiedostoa jossa 69 lisäystä ja 63 poistoa
  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 Näytä tiedosto


BIN
BlackRock.Reporting.API/BlackRock.db-wal Näytä tiedosto


BlackRock.Reporting.API/Mediator/Model/ErrorResponse.cs → BlackRock.Reporting.API/Controllers/Model/ErrorResponse.cs Näytä tiedosto

@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc.ModelBinding;

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

+ 5
- 3
BlackRock.Reporting.API/Controllers/UsersController.cs Näytä tiedosto

@@ -1,11 +1,13 @@
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 Microsoft.AspNetCore.Mvc;
using BlackRock.Reporting.API.Mediator.Model;

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

+ 0
- 3
BlackRock.Reporting.API/Core/IRepository.cs Näytä tiedosto

@@ -1,7 +1,4 @@
using System.Linq.Expressions;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Persistence;

namespace BlackRock.Reporting.API.Core
{

+ 3
- 4
BlackRock.Reporting.API/Core/IUsersRepository.cs Näytä tiedosto

@@ -1,12 +1,11 @@
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
{
public interface IUsersRepository : IRepository<User>
{
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 Näytä tiedosto

@@ -1,4 +1,4 @@
namespace BlackRock.Reporting.API.Models
namespace BlackRock.Reporting.API.Core.Models
{
public interface IBaseEntity
{

BlackRock.Reporting.API/Mediator/Model/IPaggingAndFiltering.cs → BlackRock.Reporting.API/Core/Models/IPaggingAndFiltering.cs Näytä tiedosto

@@ -1,8 +1,7 @@
namespace BlackRock.Reporting.API.Mediator.Model
namespace BlackRock.Reporting.API.Core.Models
{
public interface IPaggingAndFiltering
{
string EmailDomain {get;set;}
string SortBy { get; set; }
bool IsSortAscending { get; set; }
int Page { get; set; }

+ 7
- 0
BlackRock.Reporting.API/Core/Models/IUserPaggingAndFiltering.cs Näytä tiedosto

@@ -0,0 +1,7 @@
namespace BlackRock.Reporting.API.Core.Models
{
public interface IUserPaggingAndFiltering : IPaggingAndFiltering
{
string EmailDomain {get;set;}
}
}

+ 18
- 0
BlackRock.Reporting.API/Core/Models/PaggingAndFiltering.cs Näytä tiedosto

@@ -0,0 +1,18 @@
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 Näytä tiedosto

@@ -1,13 +1,12 @@
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 string SortBy {set;get;}
public string? SortBy {set;get;}
public bool IsSortAscending {set;get;}
public int Page {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 Näytä tiedosto

@@ -1,6 +1,6 @@
using BlackRock.Reporting.API.Core.Models;

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

+ 1
- 2
BlackRock.Reporting.API/Extensions/IQueryableExtensions.cs Näytä tiedosto

@@ -1,6 +1,5 @@
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
{

BlackRock.Reporting.API/Mediator/CreateUsersCommand.cs → BlackRock.Reporting.API/Mediator/Commands/CreateUsersCommand.cs Näytä tiedosto

@@ -1,10 +1,10 @@
using AutoMapper;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using MediatR;

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

BlackRock.Reporting.API/Mediator/DeleteUsersCommand.cs → BlackRock.Reporting.API/Mediator/Commands/DeleteUsersCommand.cs Näytä tiedosto

@@ -1,10 +1,9 @@
using AutoMapper;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using MediatR;

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

BlackRock.Reporting.API/Mediator/UpdateAllUsersCommand.cs → BlackRock.Reporting.API/Mediator/Commands/UpdateAllUsersCommand.cs Näytä tiedosto

@@ -1,11 +1,11 @@
using AutoMapper;
using BlackRock.Reporting.API.Controllers.Dto;
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.Models;
using MediatR;

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

BlackRock.Reporting.API/Mediator/UpdateEmailUsersCommand.cs → BlackRock.Reporting.API/Mediator/Commands/UpdateEmailUsersCommand.cs Näytä tiedosto

@@ -1,11 +1,11 @@
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.Models;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using MediatR;

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

BlackRock.Reporting.API/Controllers/Dto/UserDto.cs → BlackRock.Reporting.API/Mediator/Dto/UserDto.cs Näytä tiedosto

@@ -1,4 +1,4 @@
namespace BlackRock.Reporting.API.Controllers.Dto
namespace BlackRock.Reporting.API.Mediator.Dto
{
public class UserDto
{

+ 0
- 11
BlackRock.Reporting.API/Mediator/Model/PaggingAndFiltering.cs Näytä tiedosto

@@ -1,11 +0,0 @@
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 Näytä tiedosto

@@ -1,4 +1,4 @@
namespace BlackRock.Reporting.API.Models
namespace BlackRock.Reporting.API.Mediator.Model
{
public class Result<TData>
{

BlackRock.Reporting.API/Mediator/GetAllUsersQuery.cs → BlackRock.Reporting.API/Mediator/Queries/GetAllUsersQuery.cs Näytä tiedosto

@@ -1,13 +1,13 @@
using AutoMapper;
using BlackRock.Reporting.API.Controllers.Dto;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Mediator.Dto;
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 Näytä tiedosto

@@ -1,11 +1,11 @@
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.Models;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using MediatR;

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

+ 1
- 1
BlackRock.Reporting.API/Persistence/BRDbContext.cs Näytä tiedosto

@@ -1,4 +1,4 @@
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Core.Models;
using Microsoft.EntityFrameworkCore;

namespace BlackRock.Reporting.API.Persistence

+ 0
- 2
BlackRock.Reporting.API/Persistence/Repository.cs Näytä tiedosto

@@ -1,7 +1,5 @@
using System.Linq.Expressions;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Models;
using Microsoft.EntityFrameworkCore;

namespace BlackRock.Reporting.API.Persistence

+ 4
- 5
BlackRock.Reporting.API/Persistence/UsersRepository.cs Näytä tiedosto

@@ -1,9 +1,7 @@
using System.Linq.Expressions;
using BlackRock.Reporting.API.Core;
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;

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

@@ -35,14 +33,15 @@ namespace BlackRock.Reporting.API.Persistence

query = query.ApplyOrdering(queryObj, columnsMap);

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

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

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

+ 1
- 2
BlackRock.Reporting.API/Profiles/Profiler.cs Näytä tiedosto

@@ -1,9 +1,8 @@
using AutoMapper;
using PuppeteerSharp;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Mediator.Model;
using BlackRock.Reporting.API.Controllers.Dto;
using BlackRock.Reporting.API.Mediator.Dto;

namespace BlackRock.Reporting.API.Profiles
{

+ 1
- 1
BlackRock.Reporting.API/Program.cs Näytä tiedosto

@@ -1,5 +1,4 @@
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Models;
using BlackRock.Reporting.API.Persistence;
using BlackRock.Reporting.API.Profiles;
using MediatR;
@@ -12,6 +11,7 @@ builder.Services.AddDbContext<BRDbContext>(config =>
//config.UseSqlServer(builder.Configuration.GetConnectionString("Default")));
config.UseSqlite("Data source=BlackRock.db"));
builder.Services.AddScoped<IGenerator, PdfGenerator>();
builder.Services.AddScoped(typeof(IRepository < > ), typeof(Repository < > ));
builder.Services.AddScoped<IUsersRepository,UsersRepository>();
builder.Services.AddScoped<IUnitOfWork,UnitOfWork>();
builder.Services.AddCors();

+ 2
- 0
BlackRock.Reporting.API/obj/staticwebassets.pack.sentinel Näytä tiedosto

@@ -45,3 +45,5 @@
2.0
2.0
2.0
2.0
2.0

Loading…
Peruuta
Tallenna