Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Join our Discord - [fullstackhero @ Discord](https://discord.gg/gdgHRt4mMw)
- [x] Dapper Integration for Optimal Performance :heavy_check_mark:
- [x] Serilog Integration :heavy_check_mark:
- [x] Swagger Support :heavy_check_mark:
- [x] Automapper :heavy_check_mark:
- [x] Mapster :heavy_check_mark:
- [x] API Versioning :heavy_check_mark:
- [x] Response Caching - Distributed Caching :heavy_check_mark:
- [x] Fluent Validations :heavy_check_mark:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public static class ServiceCollectionExtensions
{
public static IServiceCollection AddApplication(this IServiceCollection services)
{
// services.AddAutoMapper(Assembly.GetExecutingAssembly());
services.AddValidatorsFromAssemblyContaining<IRequestValidator>();
return services;
}
Expand Down
14 changes: 0 additions & 14 deletions src/Core/Application/Mappings/CatalogProfile.cs

This file was deleted.

9 changes: 1 addition & 8 deletions src/Core/Application/Services/Catalog/ProductService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// using AutoMapper;
using DN.WebApi.Application.Abstractions.Repositories;
using DN.WebApi.Application.Abstractions.Services.Catalog;
using DN.WebApi.Application.Abstractions.Services.General;
Expand All @@ -17,16 +16,12 @@ namespace DN.WebApi.Application.Services.Catalog
public class ProductService : IProductService
{
private readonly IStringLocalizer<ProductService> _localizer;

// private readonly IMapper _mapper;
private readonly IFileStorageService _file;
private readonly IRepositoryAsync _repository;

public ProductService(IRepositoryAsync repository, /*IMapper mapper, */IStringLocalizer<ProductService> localizer, IFileStorageService file)
public ProductService(IRepositoryAsync repository, IStringLocalizer<ProductService> localizer, IFileStorageService file)
{
_repository = repository;

// _mapper = mapper;
_localizer = localizer;
_file = file;
}
Expand Down Expand Up @@ -58,8 +53,6 @@ public async Task<Result<ProductDetailsDto>> GetByIdAsync(Guid id)
public async Task<Result<ProductDetailsDto>> GetByIdUsingDapperAsync(Guid id)
{
var product = await _repository.QueryFirstOrDefaultAsync<Product>($"SELECT * FROM public.\"Products\" WHERE \"Id\" = '{id}' AND \"TenantKey\"='@tenantKey'");

// var mappedProduct = _mapper.Map<ProductDetailsDto>(product);
var mappedProduct = product.Adapt<ProductDetailsDto>();
return await Result<ProductDetailsDto>.SuccessAsync(mappedProduct);
}
Expand Down
24 changes: 0 additions & 24 deletions src/Infrastructure/Extensions/MapperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

// using AutoMapper;
using DN.WebApi.Application.Wrapper;
using DN.WebApi.Shared.DTOs;
using Mapster;
Expand All @@ -21,26 +19,6 @@ public static async Task<PaginatedResult<TDto>> ToMappedPaginatedResultAsync<T,
return await converter.ConvertBackAsync(query);
}

/*
public static async Task<PaginatedResult<TDto>> ToMappedPaginatedResultAsync<T, TDto>(/*this IMapper mapper,#1#this IQueryable<T> query, int pageNumber, int pageSize)
where T : class
{
if (query == null)
{
throw new ArgumentNullException(nameof(query));
}

pageNumber = pageNumber == 0 ? 1 : pageNumber;
pageSize = pageSize == 0 ? 10 : pageSize;
int count = await query.AsNoTracking().CountAsync();
pageNumber = pageNumber <= 0 ? 1 : pageNumber;
var items = await query.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToListAsync();

// var mappedItems = mapper.Map<List<T>, List<TDto>>(items);
var mappedItems = items.Adapt<List<TDto>>();
return PaginatedResult<TDto>.Success(mappedItems, count, pageNumber, pageSize);
}
}*/
public class MappedPaginatedResultConverter<T, TDto> : IMapsterConverterAsync<PaginatedResult<TDto>, IQueryable<T>>
where T : class
{
Expand Down Expand Up @@ -70,8 +48,6 @@ public async Task<PaginatedResult<TDto>> ConvertBackAsync(IQueryable<T> query)
int count = await query.AsNoTracking().CountAsync();
_pageNumber = _pageNumber <= 0 ? 1 : _pageNumber;
var items = await query.Skip((_pageNumber - 1) * _pageSize).Take(_pageSize).ToListAsync();

// var mappedItems = mapper.Map<List<T>, List<TDto>>(items);
var mappedItems = items.Adapt<List<TDto>>();
return await Task.FromResult(PaginatedResult<TDto>.Success(mappedItems, count, _pageNumber, _pageSize));
}
Expand Down
2 changes: 0 additions & 2 deletions src/Infrastructure/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public static class ServiceCollectionExtensions
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration config)
{
services.AddHealthCheckExtension();

// services.AddAutoMapper(Assembly.GetExecutingAssembly());
services.AddLocalization();
services.AddServices(config);
services.AddDistributedMemoryCache();
Expand Down
8 changes: 1 addition & 7 deletions src/Infrastructure/Identity/Services/PermissionService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// using AutoMapper;
using DN.WebApi.Application.Abstractions.Services.General;
using DN.WebApi.Application.Abstractions.Services.Identity;
using DN.WebApi.Application.Constants;
Expand All @@ -17,18 +16,15 @@ namespace DN.WebApi.Infrastructure.Identity.Services
{
public class PermissionService : IPermissionService
{
// private readonly IMapper _mapper;
private readonly ApplicationDbContext _context;
private readonly IDistributedCache _cache;
private readonly ICurrentUser _currentUser;
private readonly ISerializerService _serializer;

public PermissionService(ApplicationDbContext context, ICurrentUser currentUser, /* IMapper mapper,*/ IDistributedCache cache, ISerializerService serializer)
public PermissionService(ApplicationDbContext context, ICurrentUser currentUser, IDistributedCache cache, ISerializerService serializer)
{
_context = context;
_currentUser = currentUser;

// _mapper = mapper;
_cache = cache;
_serializer = serializer;
}
Expand All @@ -47,8 +43,6 @@ public async Task<bool> HasPermissionAsync(string userId, string permission)
{
var userRoles = await _context.UserRoles.Where(a => a.UserId == userId).Select(a => a.RoleId).ToListAsync();
var applicationRoles = await _context.Roles.Where(a => userRoles.Contains(a.Id)).ToListAsync();

// roles = _mapper.Map<List<RoleDto>>(applicationRoles);
roles = applicationRoles.Adapt<List<RoleDto>>();
if (roles != null)
{
Expand Down
13 changes: 1 addition & 12 deletions src/Infrastructure/Identity/Services/RoleService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// using AutoMapper;
using DN.WebApi.Application.Abstractions.Services.Identity;
using DN.WebApi.Application.Exceptions;
using DN.WebApi.Application.Wrapper;
Expand Down Expand Up @@ -26,16 +25,12 @@ public class RoleService : IRoleService
private readonly ApplicationDbContext _context;
private readonly IStringLocalizer<RoleService> _localizer;

// private readonly IMapper _mapper;

public RoleService(RoleManager<ApplicationRole> roleManager, UserManager<ApplicationUser> userManager, ApplicationDbContext context, IStringLocalizer<RoleService> localizer, /* IMapper mapper,*/ ICurrentUser currentUser)
public RoleService(RoleManager<ApplicationRole> roleManager, UserManager<ApplicationUser> userManager, ApplicationDbContext context, IStringLocalizer<RoleService> localizer, ICurrentUser currentUser)
{
_roleManager = roleManager;
_userManager = userManager;
_context = context;
_localizer = localizer;

// _mapper = mapper;
_currentUser = currentUser;
}

Expand Down Expand Up @@ -81,8 +76,6 @@ public async Task<Result<string>> DeleteAsync(string id)
public async Task<Result<RoleDto>> GetByIdAsync(string id)
{
var roles = await _roleManager.Roles.SingleOrDefaultAsync(x => x.Id == id);

// var rolesResponse = _mapper.Map<RoleDto>(roles);
var rolesResponse = roles.Adapt<RoleDto>();
return await Result<RoleDto>.SuccessAsync(rolesResponse);
}
Expand All @@ -95,8 +88,6 @@ public async Task<int> GetCountAsync()
public async Task<Result<List<RoleDto>>> GetListAsync()
{
var roles = await _roleManager.Roles.ToListAsync();

// var rolesResponse = _mapper.Map<List<RoleDto>>(roles);
var rolesResponse = roles.Adapt<List<RoleDto>>();
return await Result<List<RoleDto>>.SuccessAsync(rolesResponse);
}
Expand All @@ -105,8 +96,6 @@ public async Task<Result<List<RoleDto>>> GetUserRolesAsync(string userId)
{
var userRoles = await _context.UserRoles.Where(a => a.UserId == userId).Select(a => a.RoleId).ToListAsync();
var roles = await _roleManager.Roles.Where(a => userRoles.Contains(a.Id)).ToListAsync();

// var rolesResponse = _mapper.Map<List<RoleDto>>(roles);
var rolesResponse = roles.Adapt<List<RoleDto>>();
return await Result<List<RoleDto>>.SuccessAsync(rolesResponse);
}
Expand Down
15 changes: 0 additions & 15 deletions src/Infrastructure/Mappings/RoleProfile.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Infrastructure/Mappings/TenantProfile.cs

This file was deleted.

22 changes: 0 additions & 22 deletions src/Infrastructure/Persistence/Converters/OrderByConverter.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
using System;
using System.Linq;
using DN.WebApi.Shared.DTOs;

/*using AutoMapper;*/

namespace DN.WebApi.Infrastructure.Persistence.Converters
{
/*public class OrderByConverter :
IValueConverter<string, string[]>,
IValueConverter<string[], string>
{
public string[] Convert(string orderBy, ResolutionContext context = null)
{
if (!string.IsNullOrWhiteSpace(orderBy))
{
return orderBy
.Split(',')
.Where(x => !string.IsNullOrWhiteSpace(x))
.Select(x => x.Trim()).ToArray();
}

return Array.Empty<string>();
}

public string Convert(string[] orderBy, ResolutionContext context = null) => orderBy?.Any() == true ? string.Join(",", orderBy) : null;
}*/
public class OrderByConverter : IMapsterConverter<string, string[]>
{
public string[] Convert(string item)
Expand Down
7 changes: 1 addition & 6 deletions src/Infrastructure/Services/General/TenantManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// using AutoMapper;
using DN.WebApi.Application.Abstractions.Services.General;
using DN.WebApi.Application.Abstractions.Services.Identity;
using DN.WebApi.Application.Constants;
Expand Down Expand Up @@ -32,18 +31,14 @@ public class TenantManager : ITenantManager
private readonly MultitenancySettings _options;

private readonly TenantManagementDbContext _context;

// private readonly IMapper _mapper;
private readonly ICurrentUser _user;

public TenantManager(ApplicationDbContext appContext, IStringLocalizer<TenantService> localizer, IOptions<MultitenancySettings> options, TenantManagementDbContext context, /*IMapper mapper,*/ UserManager<ApplicationUser> userManager, RoleManager<ApplicationRole> roleManager, ICurrentUser user)
public TenantManager(ApplicationDbContext appContext, IStringLocalizer<TenantService> localizer, IOptions<MultitenancySettings> options, TenantManagementDbContext context, UserManager<ApplicationUser> userManager, RoleManager<ApplicationRole> roleManager, ICurrentUser user)
{
_appContext = appContext;
_localizer = localizer;
_options = options.Value;
_context = context;

// _mapper = mapper;
_userManager = userManager;
_roleManager = roleManager;
_user = user;
Expand Down
5 changes: 1 addition & 4 deletions src/Infrastructure/Services/General/TenantService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// using AutoMapper;
using DN.WebApi.Application.Abstractions.Services.General;
using DN.WebApi.Application.Abstractions.Services.Identity;
using DN.WebApi.Application.Constants;
Expand Down Expand Up @@ -34,13 +33,11 @@ public class TenantService : ITenantService

private readonly TenantManagementDbContext _context;

// private readonly IMapper _mapper;

private HttpContext _httpContext;

private TenantDto _currentTenant;

public TenantService(IOptions<MultitenancySettings> options, IHttpContextAccessor contextAccessor, ICurrentUser currentUser, IStringLocalizer<TenantService> localizer, TenantManagementDbContext context, /*IMapper mapper,*/ IDistributedCache cache, ISerializerService serializer)
public TenantService(IOptions<MultitenancySettings> options, IHttpContextAccessor contextAccessor, ICurrentUser currentUser, IStringLocalizer<TenantService> localizer, TenantManagementDbContext context, IDistributedCache cache, ISerializerService serializer)
{
_localizer = localizer;
_options = options.Value;
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/Shared.DTOs/Shared.DTOs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<AdditionalFiles Include="..\..\..\stylecop.json" />
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
</ItemGroup>
</Project>