| 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 | ||||
| { | { |
| 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; |
| 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 | ||||
| { | { |
| 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); | |||||
| } | } | ||||
| } | } |
| namespace BlackRock.Reporting.API.Models | |||||
| namespace BlackRock.Reporting.API.Core.Models | |||||
| { | { | ||||
| public interface IBaseEntity | public interface IBaseEntity | ||||
| { | { |
| 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; } |
| namespace BlackRock.Reporting.API.Core.Models | |||||
| { | |||||
| public interface IUserPaggingAndFiltering : IPaggingAndFiltering | |||||
| { | |||||
| string EmailDomain {get;set;} | |||||
| } | |||||
| } |
| 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;} | |||||
| } | |||||
| } |
| 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;} | |||||
| } | } | ||||
| } | } |
| 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 | ||||
| { | { |
| 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 | ||||
| { | { |
| 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>> | ||||
| { | { |
| 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>> | ||||
| { | { |
| 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>> | ||||
| { | { |
| 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>> | ||||
| { | { |
| namespace BlackRock.Reporting.API.Controllers.Dto | |||||
| namespace BlackRock.Reporting.API.Mediator.Dto | |||||
| { | { | ||||
| public class UserDto | public class UserDto | ||||
| { | { |
| 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;} | |||||
| } | |||||
| } |
| namespace BlackRock.Reporting.API.Models | |||||
| namespace BlackRock.Reporting.API.Mediator.Model | |||||
| { | { | ||||
| public class Result<TData> | public class Result<TData> | ||||
| { | { |
| 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>>> | |||||
| { | { | ||||
| } | } | ||||
| 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>> | ||||
| { | { |
| 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 |
| 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 |
| 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) | ||||
| { | { |
| 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 | ||||
| { | { |
| 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 | 2.0 | ||||
| 2.0 | 2.0 | ||||
| 2.0 | 2.0 | ||||
| 2.0 | |||||
| 2.0 |