| @@ -1,6 +1,6 @@ | |||
| using Microsoft.AspNetCore.Mvc.ModelBinding; | |||
| namespace BlackRock.Reporting.API.Mediator.Model | |||
| namespace BlackRock.Reporting.API.Controllers.Model | |||
| { | |||
| public class ErrorResponse | |||
| { | |||
| @@ -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; | |||
| @@ -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 | |||
| { | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| namespace BlackRock.Reporting.API.Models | |||
| namespace BlackRock.Reporting.API.Core.Models | |||
| { | |||
| public interface IBaseEntity | |||
| { | |||
| @@ -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; } | |||
| @@ -0,0 +1,7 @@ | |||
| namespace BlackRock.Reporting.API.Core.Models | |||
| { | |||
| public interface IUserPaggingAndFiltering : IPaggingAndFiltering | |||
| { | |||
| string EmailDomain {get;set;} | |||
| } | |||
| } | |||
| @@ -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;} | |||
| } | |||
| } | |||
| @@ -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;} | |||
| } | |||
| } | |||
| @@ -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,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 | |||
| { | |||
| @@ -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>> | |||
| { | |||
| @@ -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>> | |||
| { | |||
| @@ -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>> | |||
| { | |||
| @@ -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>> | |||
| { | |||
| @@ -1,4 +1,4 @@ | |||
| namespace BlackRock.Reporting.API.Controllers.Dto | |||
| namespace BlackRock.Reporting.API.Mediator.Dto | |||
| { | |||
| public class UserDto | |||
| { | |||
| @@ -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;} | |||
| } | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| namespace BlackRock.Reporting.API.Models | |||
| namespace BlackRock.Reporting.API.Mediator.Model | |||
| { | |||
| public class Result<TData> | |||
| { | |||
| @@ -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>>> | |||
| { | |||
| } | |||
| @@ -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,4 +1,4 @@ | |||
| using BlackRock.Reporting.API.Models; | |||
| using BlackRock.Reporting.API.Core.Models; | |||
| using Microsoft.EntityFrameworkCore; | |||
| namespace BlackRock.Reporting.API.Persistence | |||
| @@ -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 | |||
| @@ -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,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,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(); | |||
| @@ -45,3 +45,5 @@ | |||
| 2.0 | |||
| 2.0 | |||
| 2.0 | |||
| 2.0 | |||
| 2.0 | |||