| @@ -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") | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -1,10 +0,0 @@ | |||
| using BlackRock.Reporting.API.Core.Repositories; | |||
| namespace BlackRock.Reporting.API.Core | |||
| { | |||
| public interface IUnitOfWork | |||
| { | |||
| IUsersRepository UsersRepository{get;set;} | |||
| Task SaveChangesAsync(); | |||
| } | |||
| } | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| namespace BlackRock.Reporting.API.Core | |||
| namespace BlackRock.Reporting.API.Core.Interfaces | |||
| { | |||
| public interface IPdfGenerator : IGenerator | |||
| { | |||
| } | |||
| } | |||
| @@ -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 | |||
| { | |||
| @@ -0,0 +1,9 @@ | |||
| namespace BlackRock.Reporting.API.Core.Interfaces | |||
| { | |||
| public interface IUnitOfWork | |||
| { | |||
| IUsersRepository UsersRepository { get; set; } | |||
| Task SaveChangesAsync(); | |||
| } | |||
| } | |||
| @@ -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,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,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; | |||
| @@ -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>> | |||
| @@ -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,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,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,4 +1,4 @@ | |||
| using BlackRock.Reporting.API.Core; | |||
| using BlackRock.Reporting.API.Core.Interfaces; | |||
| using iTextSharp.text; | |||
| using iTextSharp.text.pdf; | |||
| using PuppeteerSharp; | |||
| @@ -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,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,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 | |||
| { | |||
| @@ -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() | |||