Compare commits
3 Commits
0b72549143
...
b76b668097
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b76b668097 | ||
|
|
669938d677 | ||
|
|
165c9b9322 |
@@ -4,10 +4,12 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using PyroFetes.DTO.User.Request;
|
using PyroFetes.DTO.User.Request;
|
||||||
using PyroFetes.DTO.User.Response;
|
using PyroFetes.DTO.User.Response;
|
||||||
using PyroFetes.Models;
|
using PyroFetes.Models;
|
||||||
|
using PyroFetes.Repositories;
|
||||||
|
using PyroFetes.Specifications.Users;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Users;
|
namespace PyroFetes.Endpoints.Users;
|
||||||
|
|
||||||
public class ConnectUserEndpoint(PyroFetesDbContext database) : Endpoint<ConnectUserDto, GetTokenDto>
|
public class ConnectUserEndpoint(UsersRepository usersRepository) : Endpoint<ConnectUserDto, GetTokenDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -17,7 +19,7 @@ public class ConnectUserEndpoint(PyroFetesDbContext database) : Endpoint<Connect
|
|||||||
|
|
||||||
public override async Task HandleAsync(ConnectUserDto req, CancellationToken ct)
|
public override async Task HandleAsync(ConnectUserDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
User? user = await database.Users.SingleOrDefaultAsync(x => x.Name == req.Name, ct);
|
User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByNameSpec(req.Name!), ct);
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ using PasswordGenerator;
|
|||||||
using PyroFetes.DTO.User.Request;
|
using PyroFetes.DTO.User.Request;
|
||||||
using PyroFetes.DTO.User.Response;
|
using PyroFetes.DTO.User.Response;
|
||||||
using PyroFetes.Models;
|
using PyroFetes.Models;
|
||||||
|
using PyroFetes.Repositories;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Users;
|
namespace PyroFetes.Endpoints.Users;
|
||||||
|
|
||||||
public class CreateUserEndpoint(PyroFetesDbContext database) : Endpoint<CreateUserDto, GetUserDto>
|
public class CreateUserEndpoint(
|
||||||
|
UsersRepository usersRepository,
|
||||||
|
AutoMapper.IMapper mapper) : Endpoint<CreateUserDto, GetUserDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -27,20 +30,8 @@ public class CreateUserEndpoint(PyroFetesDbContext database) : Endpoint<CreateUs
|
|||||||
Fonction = req.Fonction
|
Fonction = req.Fonction
|
||||||
};
|
};
|
||||||
|
|
||||||
database.Users.Add(user);
|
await usersRepository.AddAsync(user, ct);
|
||||||
|
|
||||||
await database.SaveChangesAsync(ct);
|
await Send.OkAsync(mapper.Map<GetUserDto>(user), ct);
|
||||||
|
|
||||||
GetUserDto responseDto = new()
|
|
||||||
{
|
|
||||||
Id = user.Id,
|
|
||||||
Name = user.Name,
|
|
||||||
Password = user.Password,
|
|
||||||
Salt = user.Salt,
|
|
||||||
Email = user.Email,
|
|
||||||
Fonction = user.Fonction
|
|
||||||
};
|
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.Models;
|
using PyroFetes.Models;
|
||||||
|
using PyroFetes.Repositories;
|
||||||
|
using PyroFetes.Specifications.Users;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Users;
|
namespace PyroFetes.Endpoints.Users;
|
||||||
|
|
||||||
@@ -9,7 +11,7 @@ public class DeleteUserRequest
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeleteUserEndpoint(PyroFetesDbContext database) : Endpoint<DeleteUserRequest>
|
public class DeleteUserEndpoint(UsersRepository usersRepository) : Endpoint<DeleteUserRequest>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -19,7 +21,7 @@ public class DeleteUserEndpoint(PyroFetesDbContext database) : Endpoint<DeleteUs
|
|||||||
|
|
||||||
public override async Task HandleAsync(DeleteUserRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteUserRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
User? user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
|
User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct);
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
@@ -27,8 +29,7 @@ public class DeleteUserEndpoint(PyroFetesDbContext database) : Endpoint<DeleteUs
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
database.Users.Remove(user);
|
await usersRepository.DeleteAsync(user, ct);
|
||||||
await database.SaveChangesAsync(ct);
|
|
||||||
|
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.User.Response;
|
using PyroFetes.DTO.User.Response;
|
||||||
|
using PyroFetes.Repositories;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Users;
|
namespace PyroFetes.Endpoints.Users;
|
||||||
|
|
||||||
public class GetAllUsersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetUserDto>>
|
public class GetAllUsersEndpoint(UsersRepository usersRepository) : EndpointWithoutRequest<List<GetUserDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,18 +15,6 @@ public class GetAllUsersEndpoint(PyroFetesDbContext database) : EndpointWithoutR
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetUserDto> users = await database.Users
|
await Send.OkAsync(await usersRepository.ProjectToListAsync<GetUserDto>(ct), ct);
|
||||||
.Select(users => new GetUserDto()
|
|
||||||
{
|
|
||||||
Id = users.Id,
|
|
||||||
Name = users.Name,
|
|
||||||
Password = users.Password,
|
|
||||||
Salt = users.Salt,
|
|
||||||
Email = users.Email,
|
|
||||||
Fonction = users.Fonction
|
|
||||||
})
|
|
||||||
.ToListAsync(ct);
|
|
||||||
|
|
||||||
await Send.OkAsync(users, ct);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.User.Response;
|
using PyroFetes.DTO.User.Response;
|
||||||
using PyroFetes.Models;
|
using PyroFetes.Models;
|
||||||
|
using PyroFetes.Repositories;
|
||||||
|
using PyroFetes.Specifications.Users;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Users;
|
namespace PyroFetes.Endpoints.Users;
|
||||||
|
|
||||||
@@ -10,7 +12,9 @@ public class GetUserRequest
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetUserEndpoint(PyroFetesDbContext database) : Endpoint<GetUserRequest, GetUserDto>
|
public class GetUserEndpoint(
|
||||||
|
UsersRepository usersRepository,
|
||||||
|
AutoMapper.IMapper mapper) : Endpoint<GetUserRequest, GetUserDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -20,8 +24,7 @@ public class GetUserEndpoint(PyroFetesDbContext database) : Endpoint<GetUserRequ
|
|||||||
|
|
||||||
public override async Task HandleAsync(GetUserRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetUserRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
User? user = await database.Users
|
User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct);
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
|
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
@@ -29,16 +32,6 @@ public class GetUserEndpoint(PyroFetesDbContext database) : Endpoint<GetUserRequ
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetUserDto responseDto = new()
|
await Send.OkAsync(mapper.Map<GetUserDto>(user), ct);
|
||||||
{
|
|
||||||
Id = user.Id,
|
|
||||||
Name = user.Name,
|
|
||||||
Password = user.Password,
|
|
||||||
Salt = user.Salt,
|
|
||||||
Email = user.Email,
|
|
||||||
Fonction = user.Fonction
|
|
||||||
};
|
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,14 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using PyroFetes.DTO.User.Request;
|
using PyroFetes.DTO.User.Request;
|
||||||
using PyroFetes.DTO.User.Response;
|
using PyroFetes.DTO.User.Response;
|
||||||
using PyroFetes.Models;
|
using PyroFetes.Models;
|
||||||
|
using PyroFetes.Repositories;
|
||||||
|
using PyroFetes.Specifications.Users;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Users;
|
namespace PyroFetes.Endpoints.Users;
|
||||||
|
|
||||||
public class PatchUserPasswordEndpoint(PyroFetesDbContext database) : Endpoint<PatchUserPasswordDto, GetUserDto>
|
public class PatchUserPasswordEndpoint(
|
||||||
|
UsersRepository usersRepository,
|
||||||
|
AutoMapper.IMapper mapper) : Endpoint<PatchUserPasswordDto, GetUserDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -16,7 +20,8 @@ public class PatchUserPasswordEndpoint(PyroFetesDbContext database) : Endpoint<P
|
|||||||
|
|
||||||
public override async Task HandleAsync(PatchUserPasswordDto req, CancellationToken ct)
|
public override async Task HandleAsync(PatchUserPasswordDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
User? user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
|
User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct);
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
@@ -24,17 +29,8 @@ public class PatchUserPasswordEndpoint(PyroFetesDbContext database) : Endpoint<P
|
|||||||
}
|
}
|
||||||
|
|
||||||
user.Password = BCrypt.Net.BCrypt.HashPassword(req.Password + user.Salt);
|
user.Password = BCrypt.Net.BCrypt.HashPassword(req.Password + user.Salt);
|
||||||
await database.SaveChangesAsync(ct);
|
await usersRepository.UpdateAsync(user, ct);
|
||||||
|
|
||||||
GetUserDto responseDto = new()
|
await Send.OkAsync(mapper.Map<GetUserDto>(user), ct);
|
||||||
{
|
|
||||||
Id = user.Id,
|
|
||||||
Name = user.Name,
|
|
||||||
Password = user.Password,
|
|
||||||
Salt = user.Salt,
|
|
||||||
Email = user.Email,
|
|
||||||
Fonction = user.Fonction
|
|
||||||
};
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,14 @@ using PasswordGenerator;
|
|||||||
using PyroFetes.DTO.User.Request;
|
using PyroFetes.DTO.User.Request;
|
||||||
using PyroFetes.DTO.User.Response;
|
using PyroFetes.DTO.User.Response;
|
||||||
using PyroFetes.Models;
|
using PyroFetes.Models;
|
||||||
|
using PyroFetes.Repositories;
|
||||||
|
using PyroFetes.Specifications.Users;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Users;
|
namespace PyroFetes.Endpoints.Users;
|
||||||
|
|
||||||
public class UpdateUserEndpoint(PyroFetesDbContext database) : Endpoint<UpdateUserDto, GetUserDto>
|
public class UpdateUserEndpoint(
|
||||||
|
UsersRepository usersRepository,
|
||||||
|
AutoMapper.IMapper mapper) : Endpoint<UpdateUserDto, GetUserDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -17,8 +21,8 @@ public class UpdateUserEndpoint(PyroFetesDbContext database) : Endpoint<UpdateUs
|
|||||||
|
|
||||||
public override async Task HandleAsync(UpdateUserDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateUserDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
User? user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
|
User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct);
|
||||||
User? ckeckName = await database.Users.SingleOrDefaultAsync(x => x.Name == req.Name, ct);
|
User? ckeckName = await usersRepository.FirstOrDefaultAsync(new GetUserByNameSpec(req.Name!), ct);
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
@@ -39,18 +43,9 @@ public class UpdateUserEndpoint(PyroFetesDbContext database) : Endpoint<UpdateUs
|
|||||||
user.Salt = salt;
|
user.Salt = salt;
|
||||||
user.Email = req.Email;
|
user.Email = req.Email;
|
||||||
user.Fonction = req.Fonction;
|
user.Fonction = req.Fonction;
|
||||||
await database.SaveChangesAsync(ct);
|
|
||||||
|
|
||||||
GetUserDto responseDto = new()
|
await usersRepository.UpdateAsync(user, ct);
|
||||||
{
|
|
||||||
Id = user.Id,
|
|
||||||
Name = user.Name,
|
|
||||||
Password = user.Password,
|
|
||||||
Salt = user.Salt,
|
|
||||||
Email = user.Email,
|
|
||||||
Fonction = user.Fonction
|
|
||||||
};
|
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(mapper.Map<GetUserDto>(user), ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.WareHouseProduct.Response;
|
using PyroFetes.DTO.WareHouseProduct.Response;
|
||||||
using PyroFetes.Models;
|
using PyroFetes.Models;
|
||||||
|
using PyroFetes.Repositories;
|
||||||
|
using PyroFetes.Specifications.WarehouseProducts;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.WareHouseProducts;
|
namespace PyroFetes.Endpoints.WareHouseProducts;
|
||||||
|
|
||||||
@@ -10,7 +12,8 @@ public class GetTotalQuantityRequest
|
|||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetTotalQuantityEndpoint(PyroFetesDbContext database) : Endpoint<GetTotalQuantityRequest, GetTotalQuantityDto>
|
public class GetTotalQuantityEndpoint(
|
||||||
|
WarehouseProductsRepository warehouseProductsRepository) : Endpoint<GetTotalQuantityRequest, GetTotalQuantityDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -20,8 +23,7 @@ public class GetTotalQuantityEndpoint(PyroFetesDbContext database) : Endpoint<Ge
|
|||||||
|
|
||||||
public override async Task HandleAsync(GetTotalQuantityRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetTotalQuantityRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
bool exists = await database.WarehouseProducts
|
bool exists = await warehouseProductsRepository.AnyAsync(new GetWarehouseProductByProductIdSpec(req.ProductId), ct);
|
||||||
.AnyAsync(wp => wp.ProductId == req.ProductId, ct);
|
|
||||||
|
|
||||||
if (!exists)
|
if (!exists)
|
||||||
{
|
{
|
||||||
@@ -29,9 +31,9 @@ public class GetTotalQuantityEndpoint(PyroFetesDbContext database) : Endpoint<Ge
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalQuantity = await database.WarehouseProducts
|
int totalQuantity =
|
||||||
.Where(wp => wp.ProductId == req.ProductId)
|
await warehouseProductsRepository.SumAsync(new GetProductTotalQuantitySpec(req.ProductId),
|
||||||
.SumAsync(wp => wp.Quantity, ct);
|
wp => wp.Quantity, ct);
|
||||||
|
|
||||||
GetTotalQuantityDto responseDto = new()
|
GetTotalQuantityDto responseDto = new()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,20 @@ builder.Services
|
|||||||
.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
|
.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
|
||||||
.AddAuthorization()
|
.AddAuthorization()
|
||||||
.AddFastEndpoints()
|
.AddFastEndpoints()
|
||||||
.SwaggerDocument();
|
.SwaggerDocument(options =>
|
||||||
|
{
|
||||||
|
options.ShortSchemaNames = true;
|
||||||
|
})
|
||||||
|
.AddCors(options =>
|
||||||
|
{
|
||||||
|
options.AddDefaultPolicy(policyBuilder =>
|
||||||
|
{
|
||||||
|
policyBuilder
|
||||||
|
.WithOrigins("http://localhost:4200")
|
||||||
|
.WithMethods("GET", "POST", "PUT", "DELETE", "PATCH")
|
||||||
|
.AllowAnyHeader();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// On ajoute ici la configuration de la base de données
|
// On ajoute ici la configuration de la base de données
|
||||||
builder.Services.AddDbContext<PyroFetesDbContext>();
|
builder.Services.AddDbContext<PyroFetesDbContext>();
|
||||||
@@ -30,6 +43,8 @@ builder.Services.AddScoped<QuotationProductsRepository>();
|
|||||||
builder.Services.AddScoped<QuotationsRepository>();
|
builder.Services.AddScoped<QuotationsRepository>();
|
||||||
builder.Services.AddScoped<SuppliersRepository>();
|
builder.Services.AddScoped<SuppliersRepository>();
|
||||||
builder.Services.AddScoped<SettingsRepository>();
|
builder.Services.AddScoped<SettingsRepository>();
|
||||||
|
builder.Services.AddScoped<UsersRepository>();
|
||||||
|
builder.Services.AddScoped<WarehouseProductsRepository>();
|
||||||
|
|
||||||
MapperConfiguration mappingConfig = new(mc =>
|
MapperConfiguration mappingConfig = new(mc =>
|
||||||
{
|
{
|
||||||
@@ -46,9 +61,15 @@ builder.Services.AddSingleton(mapper);
|
|||||||
WebApplication app = builder.Build();
|
WebApplication app = builder.Build();
|
||||||
app.UseAuthentication()
|
app.UseAuthentication()
|
||||||
.UseAuthorization()
|
.UseAuthorization()
|
||||||
.UseFastEndpoints()
|
.UseFastEndpoints(options =>
|
||||||
|
{
|
||||||
|
options.Endpoints.ShortNames = true;
|
||||||
|
options.Endpoints.RoutePrefix = "API";
|
||||||
|
})
|
||||||
.UseSwaggerGen();
|
.UseSwaggerGen();
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseCors();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
@@ -59,9 +59,9 @@ public class PyrofetesRepository<T>(DbContext databaseContext, AutoMapper.IMappe
|
|||||||
/// <param name="selector"></param>
|
/// <param name="selector"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<decimal> SumAsync(
|
public async Task<int> SumAsync(
|
||||||
ISpecification<T> specification,
|
ISpecification<T> specification,
|
||||||
Expression<Func<T, decimal>> selector,
|
Expression<Func<T, int>> selector,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return await ApplySpecification(specification).SumAsync(selector, cancellationToken);
|
return await ApplySpecification(specification).SumAsync(selector, cancellationToken);
|
||||||
|
|||||||
5
PyroFetes/Repositories/UsersRepository.cs
Normal file
5
PyroFetes/Repositories/UsersRepository.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Repositories;
|
||||||
|
|
||||||
|
public class UsersRepository(PyroFetesDbContext pyrofetesContext, AutoMapper.IMapper mapper) : PyrofetesRepository<User>(pyrofetesContext, mapper);
|
||||||
5
PyroFetes/Repositories/WarehouseProductsRepository.cs
Normal file
5
PyroFetes/Repositories/WarehouseProductsRepository.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Repositories;
|
||||||
|
|
||||||
|
public class WarehouseProductsRepository(PyroFetesDbContext pyrofetesContext, AutoMapper.IMapper mapper) : PyrofetesRepository<WarehouseProduct>(pyrofetesContext, mapper);
|
||||||
13
PyroFetes/Specifications/Users/GetUserByIdSpec.cs
Normal file
13
PyroFetes/Specifications/Users/GetUserByIdSpec.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Ardalis.Specification;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Specifications.Users;
|
||||||
|
|
||||||
|
public sealed class GetUserByIdSpec : Specification<User>
|
||||||
|
{
|
||||||
|
public GetUserByIdSpec(int userId)
|
||||||
|
{
|
||||||
|
Query
|
||||||
|
.Where(x => x.Id == userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
PyroFetes/Specifications/Users/GetUserByNameSpec.cs
Normal file
13
PyroFetes/Specifications/Users/GetUserByNameSpec.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Ardalis.Specification;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Specifications.Users;
|
||||||
|
|
||||||
|
public sealed class GetUserByNameSpec : Specification<User>
|
||||||
|
{
|
||||||
|
public GetUserByNameSpec(string userName)
|
||||||
|
{
|
||||||
|
Query
|
||||||
|
.Where(x=> x.Name == userName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using Ardalis.Specification;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Specifications.WarehouseProducts;
|
||||||
|
|
||||||
|
public sealed class GetProductTotalQuantitySpec : Specification<WarehouseProduct>
|
||||||
|
{
|
||||||
|
public GetProductTotalQuantitySpec(int productId)
|
||||||
|
{
|
||||||
|
Query
|
||||||
|
.Where(wp => wp.ProductId == productId);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using Ardalis.Specification;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Specifications.WarehouseProducts;
|
||||||
|
|
||||||
|
public sealed class GetWarehouseProductByProductIdSpec : Specification<WarehouseProduct>
|
||||||
|
{
|
||||||
|
public GetWarehouseProductByProductIdSpec(int productId)
|
||||||
|
{
|
||||||
|
Query
|
||||||
|
.Where(x => x.ProductId == productId);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user