소스 검색

More refactoring for clean architecture

master
Safet Purkovic 4 년 전
부모
커밋
53c04cc94b

+ 3
- 3
BlackRock.Reporting.API/Controllers/PDFGeneratorController.cs 파일 보기

@@ -1,6 +1,6 @@
using System.Web;
using AutoMapper;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Interfaces;
using BlackRock.Reporting.API.Core.Models;
using Microsoft.AspNetCore.Mvc;
using PuppeteerSharp;
@@ -35,14 +35,14 @@ namespace BlackRock.Reporting.API.Controllers
string path = Path.Combine(host.ContentRootPath, $"wwwroot/pdfs/{fileName}");
// Mapping from DTO class to Puppeteer PdfOptions class. For margins and paper format
var options = mapper.Map<OptionsForPdf, PdfOptions>(pdfOptions);
await generator.Generate(result, path, options);

FileStream stream = new FileStream(path, FileMode.Open);
return File(stream, "application/pdf", fileName);
}


[HttpGet("isolate/{url}")]
public async Task<IActionResult> GetIsolated([FromQuery] OptionsForPdf pdfOptions, string url = "http://localhost:3000/#/dashboard")

+ 0
- 10
BlackRock.Reporting.API/Core/IGenerator.cs 파일 보기

@@ -1,10 +0,0 @@
using PuppeteerSharp;

namespace BlackRock.Reporting.API.Core
{
public interface IGenerator
{
Task Generate(string url, string path,PdfOptions options);
Task Isolate(string url, string path,PdfOptions options);
}
}

+ 0
- 10
BlackRock.Reporting.API/Core/IUnitOfWork.cs 파일 보기

@@ -1,10 +0,0 @@
using BlackRock.Reporting.API.Core.Repositories;

namespace BlackRock.Reporting.API.Core
{
public interface IUnitOfWork
{
IUsersRepository UsersRepository{get;set;}
Task SaveChangesAsync();
}
}

+ 10
- 0
BlackRock.Reporting.API/Core/Interfaces/IGenerator.cs 파일 보기

@@ -0,0 +1,10 @@
using PuppeteerSharp;

namespace BlackRock.Reporting.API.Core.Interfaces
{
public interface IGenerator
{
Task Generate(string url, string path, PdfOptions options);
Task Isolate(string url, string path, PdfOptions options);
}
}

BlackRock.Reporting.API/Core/IPdfGenerator.cs → BlackRock.Reporting.API/Core/Interfaces/IPdfGenerator.cs 파일 보기

@@ -1,7 +1,7 @@
namespace BlackRock.Reporting.API.Core
namespace BlackRock.Reporting.API.Core.Interfaces
{
public interface IPdfGenerator : IGenerator
{
}
}

BlackRock.Reporting.API/Core/Repositories/IRepository.cs → BlackRock.Reporting.API/Core/Interfaces/IRepository.cs 파일 보기

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

namespace BlackRock.Reporting.API.Core.Repositories
namespace BlackRock.Reporting.API.Core.Interfaces
{
public interface IRepository<TEntity> where TEntity : class, IBaseEntity
{

+ 9
- 0
BlackRock.Reporting.API/Core/Interfaces/IUnitOfWork.cs 파일 보기

@@ -0,0 +1,9 @@

namespace BlackRock.Reporting.API.Core.Interfaces
{
public interface IUnitOfWork
{
IUsersRepository UsersRepository { get; set; }
Task SaveChangesAsync();
}
}

BlackRock.Reporting.API/Core/Repositories/IUsersRepository.cs → BlackRock.Reporting.API/Core/Interfaces/IUsersRepository.cs 파일 보기

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

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

+ 1
- 1
BlackRock.Reporting.API/Mediator/UserMediator/Commands/CreateUserCommand.cs 파일 보기

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

+ 1
- 1
BlackRock.Reporting.API/Mediator/UserMediator/Commands/DeleteUsersCommand.cs 파일 보기

@@ -1,5 +1,5 @@
using AutoMapper;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Interfaces;
using BlackRock.Reporting.API.Mediator.UserMediator.Model;
using MediatR;


+ 4
- 4
BlackRock.Reporting.API/Mediator/UserMediator/Commands/UpdateUserCommand.cs 파일 보기

@@ -1,5 +1,5 @@
using AutoMapper;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Interfaces;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Mediator.UserMediator.Dto;
using BlackRock.Reporting.API.Mediator.UserMediator.Model;
@@ -9,9 +9,9 @@ namespace BlackRock.Reporting.API.Mediator.UserMediator.Commands
{
public class UpdateUserCommand : IRequest<Result<UserDto>>
{
public UserCommand User { get;set; }
public int Id { get;set; }
public UserCommand User { get; set; }
public int Id { get; set; }
}

public class UpdateUserCommandHandlers : IRequestHandler<UpdateUserCommand, Result<UserDto>>

+ 5
- 5
BlackRock.Reporting.API/Mediator/UserMediator/Commands/UpdateUserEmailCommand.cs 파일 보기

@@ -1,7 +1,7 @@
using AutoMapper;
using BlackRock.Reporting.API.Mediator.UserMediator.Dto;
using BlackRock.Reporting.API.Mediator.UserMediator.Model;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Interfaces;
using BlackRock.Reporting.API.Core.Models;
using MediatR;

@@ -9,9 +9,9 @@ namespace BlackRock.Reporting.API.Mediator.UserMediator.Commands
{
public class UpdateUserEmailCommand : IRequest<Result<UserDto>>
{
public UserCommand User {set;get;}
public int Id { get; set;}
public UserCommand User { set; get; }
public int Id { get; set; }
}

public class UpdateUserEmailCommandHandlers : IRequestHandler<UpdateUserEmailCommand, Result<UserDto>>
@@ -33,7 +33,7 @@ namespace BlackRock.Reporting.API.Mediator.UserMediator.Commands
try
{
var user = await unitOfWork.UsersRepository.GetByIdAsync(command.Id);
unitOfWork.UsersRepository.UpdateEmail(user,command.User.Email);
unitOfWork.UsersRepository.UpdateEmail(user, command.User.Email);
await unitOfWork.SaveChangesAsync();
var updatedUser = mapper.Map<User, UserDto>(user);
logger.LogInformation($"Email of the user with id {user.Id} has been updated successfully");

+ 1
- 1
BlackRock.Reporting.API/Mediator/UserMediator/Queries/GetAllUsersQuery.cs 파일 보기

@@ -1,5 +1,5 @@
using AutoMapper;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Interfaces;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Mediator.UserMediator.Model;
using BlackRock.Reporting.API.Mediator.UserMediator.Dto;

+ 1
- 2
BlackRock.Reporting.API/Mediator/UserMediator/Queries/GetUserQuery.cs 파일 보기

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

namespace BlackRock.Reporting.API.Mediator.UserMediator.Queries
{

+ 1
- 1
BlackRock.Reporting.API/Persistence/PdfGenerator.cs 파일 보기

@@ -1,4 +1,4 @@
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Interfaces;
using iTextSharp.text;
using iTextSharp.text.pdf;
using PuppeteerSharp;

+ 1
- 1
BlackRock.Reporting.API/Persistence/Repositories/EFRepository.cs 파일 보기

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


+ 1
- 1
BlackRock.Reporting.API/Persistence/Repositories/UsersRepository.cs 파일 보기

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

+ 1
- 1
BlackRock.Reporting.API/Persistence/UnitOfWork.cs 파일 보기

@@ -1,5 +1,5 @@
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Repositories;
using BlackRock.Reporting.API.Core.Interfaces;

namespace BlackRock.Reporting.API.Persistence
{

+ 5
- 5
BlackRock.Reporting.API/Program.cs 파일 보기

@@ -1,7 +1,6 @@
using BlackRock.Reporting.API.Authentication;
using BlackRock.Reporting.API.Core;
using BlackRock.Reporting.API.Core.Models;
using BlackRock.Reporting.API.Core.Repositories;
using BlackRock.Reporting.API.Core.Interfaces;
using BlackRock.Reporting.API.Persistence;
using BlackRock.Reporting.API.Persistence.Repositories;
using MediatR;
@@ -26,7 +25,7 @@ builder.Services.AddCors();
builder.Services.AddControllers();
builder.Services.AddAutoMapper(typeof(Program));
builder.Services.AddIdentity<ApplicationUser, IdentityRole>()
.AddTokenProvider("MyApp",typeof(DataProtectorTokenProvider<ApplicationUser>))
.AddTokenProvider("MyApp", typeof(DataProtectorTokenProvider<ApplicationUser>))
.AddEntityFrameworkStores<BRDbContext>()
.AddDefaultTokenProviders();
builder.Services.AddAuthentication(options =>
@@ -52,7 +51,8 @@ builder.Services.AddAuthentication(options =>
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(
c => {
c =>
{
c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "BlackRock.Service.API", Version = "v1" });
c.AddSecurityDefinition("Bearer", new Microsoft.OpenApi.Models.OpenApiSecurityScheme
{
@@ -84,7 +84,7 @@ builder.Services.AddMediatR(typeof(Program));
var app = builder.Build();

// Configure the HTTP request pipeline.
app.ConfigureExceptionHandler(builder.Logging);
// app.ConfigureExceptionHandler(builder.Logging);
app.UseCors(options =>
options.AllowAnyHeader()
.AllowAnyMethod()

Loading…
취소
저장