forked from sanchezvem/PyroFetes
MaJ des .txt en .cs
This commit is contained in:
@@ -2,9 +2,9 @@ using API.DTO.Color.Request;
|
|||||||
using API.DTO.Color.Response;
|
using API.DTO.Color.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
|
||||||
namespace API.Endpoints.Color;
|
namespace PyroFetes.Endpoints.Color;
|
||||||
|
|
||||||
public class CreateColorEndpoint(AppDbContext appDbContext) : Endpoint<CreateColorDto, GetColorDto>
|
public class CreateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateColorDto, GetColorDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -19,8 +19,8 @@ public class CreateColorEndpoint(AppDbContext appDbContext) : Endpoint<CreateCol
|
|||||||
Label = req.Label,
|
Label = req.Label,
|
||||||
};
|
};
|
||||||
|
|
||||||
appDbContext.Colors.Add(color);
|
pyrofetesdbcontext.Colors.Add(color);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
Console.WriteLine("Added Color");
|
Console.WriteLine("Added Color");
|
||||||
|
|
||||||
GetColorDto responseDto = new()
|
GetColorDto responseDto = new()
|
@@ -1,14 +1,14 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Color;
|
namespace PyroFetes.Endpoints.Color;
|
||||||
|
|
||||||
public class DeleteColorRequest
|
public class DeleteColorRequest
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeleteColorEndpoint(AppDbContext appDbContext) : Endpoint<DeleteColorRequest>
|
public class DeleteColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteColorRequest>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -18,7 +18,7 @@ public class DeleteColorEndpoint(AppDbContext appDbContext) : Endpoint<DeleteCol
|
|||||||
|
|
||||||
public override async Task HandleAsync(DeleteColorRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteColorRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Color? colorToDelete = await appDbContext
|
Models.Color? colorToDelete = await pyrofetesdbcontext
|
||||||
.Colors
|
.Colors
|
||||||
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -29,8 +29,8 @@ public class DeleteColorEndpoint(AppDbContext appDbContext) : Endpoint<DeleteCol
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
appDbContext.Colors.Remove(colorToDelete);
|
pyrofetesdbcontext.Colors.Remove(colorToDelete);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
@@ -2,9 +2,9 @@ using API.DTO.Color.Response;
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Color;
|
namespace PyroFetes.Endpoints.Color;
|
||||||
|
|
||||||
public class GetAllColorsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest<List<GetColorDto>>
|
public class GetAllColorsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetColorDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@ public class GetAllColorsEndpoint(AppDbContext appDbContext) : EndpointWithoutRe
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetColorDto> responseDto = await appDbContext.Colors
|
List<GetColorDto> responseDto = await pyrofetesdbcontext.Colors
|
||||||
.Select(a => new GetColorDto
|
.Select(a => new GetColorDto
|
||||||
{
|
{
|
||||||
Id = a.Id,
|
Id = a.Id,
|
@@ -1,16 +1,15 @@
|
|||||||
using API.DTO.Color.Response;
|
using API.DTO.Color.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Color;
|
namespace PyroFetes.Endpoints.Color;
|
||||||
|
|
||||||
public class GetColorRequest
|
public class GetColorRequest
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetColorEndpoint(AppDbContext appDbContext) : Endpoint<GetColorRequest, GetColorDto>
|
public class GetColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetColorRequest, GetColorDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -20,7 +19,7 @@ public class GetColorEndpoint(AppDbContext appDbContext) : Endpoint<GetColorRequ
|
|||||||
|
|
||||||
public override async Task HandleAsync(GetColorRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetColorRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Color? color = await appDbContext
|
Models.Color? color = await pyrofetesdbcontext
|
||||||
.Colors
|
.Colors
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
@@ -1,12 +1,11 @@
|
|||||||
using API.DTO.Color.Request;
|
using API.DTO.Color.Request;
|
||||||
using API.DTO.Color.Response;
|
using API.DTO.Color.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Color;
|
namespace PyroFetes.Endpoints.Color;
|
||||||
|
|
||||||
public class UpdateColorEndpoint(AppDbContext appDbContext) : Endpoint<UpdateColorDto, GetColorDto>
|
public class UpdateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateColorDto, GetColorDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -16,7 +15,7 @@ public class UpdateColorEndpoint(AppDbContext appDbContext) : Endpoint<UpdateCol
|
|||||||
|
|
||||||
public override async Task HandleAsync(UpdateColorDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateColorDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Color? colorToEdit = await appDbContext
|
Models.Color? colorToEdit = await pyrofetesdbcontext
|
||||||
.Colors
|
.Colors
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ public class UpdateColorEndpoint(AppDbContext appDbContext) : Endpoint<UpdateCol
|
|||||||
|
|
||||||
}
|
}
|
||||||
colorToEdit.Label = req.Label;
|
colorToEdit.Label = req.Label;
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
GetColorDto responseDto = new()
|
GetColorDto responseDto = new()
|
||||||
{
|
{
|
@@ -1,10 +1,10 @@
|
|||||||
using API.DTO.Effect.Request;
|
using API.DTO.Effect.Request;
|
||||||
using API.DTO.Effect.Response;
|
using API.DTO.Effect.Response;
|
||||||
|
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
namespace API.Endpoints.Effect;
|
|
||||||
|
|
||||||
public class CreateEffectEndpoint(AppDbContext appDbContext) : Endpoint<CreateEffectDto, GetEffectDto>
|
namespace PyroFetes.Endpoints.Effect;
|
||||||
|
|
||||||
|
public class CreateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateEffectDto, GetEffectDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -19,8 +19,8 @@ public class CreateEffectEndpoint(AppDbContext appDbContext) : Endpoint<CreateEf
|
|||||||
Label = req.Label,
|
Label = req.Label,
|
||||||
};
|
};
|
||||||
|
|
||||||
appDbContext.Effects.Add(effect);
|
pyrofetesdbcontext.Effects.Add(effect);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
Console.WriteLine("Effect added");
|
Console.WriteLine("Effect added");
|
||||||
|
|
||||||
GetEffectDto responseDto = new()
|
GetEffectDto responseDto = new()
|
@@ -1,13 +1,13 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Effect;
|
namespace PyroFetes.Endpoints.Effect;
|
||||||
|
|
||||||
public class DeleteEffectRequest
|
public class DeleteEffectRequest
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
public class DeleteEffectEndpoint(AppDbContext appDbContext) : Endpoint<DeleteEffectRequest>
|
public class DeleteEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteEffectRequest>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ public class DeleteEffectEndpoint(AppDbContext appDbContext) : Endpoint<DeleteEf
|
|||||||
|
|
||||||
public override async Task HandleAsync(DeleteEffectRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteEffectRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Effect? effectToDelete = await appDbContext
|
Models.Effect? effectToDelete = await pyrofetesdbcontext
|
||||||
.Effects
|
.Effects
|
||||||
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -28,8 +28,8 @@ public class DeleteEffectEndpoint(AppDbContext appDbContext) : Endpoint<DeleteEf
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
appDbContext.Effects.Remove(effectToDelete);
|
pyrofetesdbcontext.Effects.Remove(effectToDelete);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
@@ -2,9 +2,9 @@ using API.DTO.Effect.Response;
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Effect;
|
namespace PyroFetes.Endpoints.Effect;
|
||||||
|
|
||||||
public class GetAllEffectsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest<List<GetEffectDto>>
|
public class GetAllEffectsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetEffectDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@ public class GetAllEffectsEndpoint(AppDbContext appDbContext) : EndpointWithoutR
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetEffectDto> responseDto = await appDbContext.Effects
|
List<GetEffectDto> responseDto = await pyrofetesdbcontext.Effects
|
||||||
.Select(a => new GetEffectDto
|
.Select(a => new GetEffectDto
|
||||||
{
|
{
|
||||||
Id = a.Id,
|
Id = a.Id,
|
@@ -1,16 +1,15 @@
|
|||||||
using API.DTO.Effect.Response;
|
using API.DTO.Effect.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Effect;
|
namespace PyroFetes.Endpoints.Effect;
|
||||||
|
|
||||||
public class GetEffectRequest
|
public class GetEffectRequest
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetEffectEndpoint(AppDbContext appDbContext) : Endpoint<GetEffectRequest, GetEffectDto>
|
public class GetEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetEffectRequest, GetEffectDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -20,7 +19,7 @@ public class GetEffectEndpoint(AppDbContext appDbContext) : Endpoint<GetEffectRe
|
|||||||
|
|
||||||
public override async Task HandleAsync(GetEffectRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetEffectRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Effect? effect = await appDbContext
|
Models.Effect? effect = await pyrofetesdbcontext
|
||||||
.Effects
|
.Effects
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
@@ -1,12 +1,11 @@
|
|||||||
using API.DTO.Effect.Request;
|
using API.DTO.Effect.Request;
|
||||||
using API.DTO.Effect.Response;
|
using API.DTO.Effect.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Effect;
|
namespace PyroFetes.Endpoints.Effect;
|
||||||
|
|
||||||
public class UpdateEffectEndpoint(AppDbContext appDbContext) : Endpoint<UpdateEffectDto, GetEffectDto>
|
public class UpdateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateEffectDto, GetEffectDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -16,7 +15,7 @@ public class UpdateEffectEndpoint(AppDbContext appDbContext) : Endpoint<UpdateEf
|
|||||||
|
|
||||||
public override async Task HandleAsync(UpdateEffectDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateEffectDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Effect? effectToEdit = await appDbContext
|
Models.Effect? effectToEdit = await pyrofetesdbcontext
|
||||||
.Effects
|
.Effects
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ public class UpdateEffectEndpoint(AppDbContext appDbContext) : Endpoint<UpdateEf
|
|||||||
|
|
||||||
}
|
}
|
||||||
effectToEdit.Label = req.Label;
|
effectToEdit.Label = req.Label;
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
GetEffectDto responseDto = new()
|
GetEffectDto responseDto = new()
|
||||||
{
|
{
|
@@ -1,9 +1,10 @@
|
|||||||
using API.DTO.Material.Request;
|
using API.DTO.Material.Request;
|
||||||
using API.DTO.Material.Response;
|
using API.DTO.Material.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
namespace API.Endpoints.Material;
|
|
||||||
|
|
||||||
public class CreateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<CreateMaterialDto, GetMaterialDto>
|
namespace PyroFetes.Endpoints.Material;
|
||||||
|
|
||||||
|
public class CreateMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateMaterialDto, GetMaterialDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -15,20 +16,20 @@ public class CreateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<Create
|
|||||||
{
|
{
|
||||||
Models.Material quantity = new()
|
Models.Material quantity = new()
|
||||||
{
|
{
|
||||||
Name = req.Name,
|
Name = req.Label,
|
||||||
Quantity = req.Quantity,
|
Quantity = req.Quantity,
|
||||||
WarehouseId = req.WarehouseId,
|
WarehouseId = req.WarehouseId,
|
||||||
};
|
};
|
||||||
|
|
||||||
appDbContext.Materials.Add(quantity);
|
pyrofetesdbcontext.Materials.Add(quantity);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
Console.WriteLine("Material added");
|
Console.WriteLine("Material added");
|
||||||
|
|
||||||
GetMaterialDto responseDto = new()
|
GetMaterialDto responseDto = new()
|
||||||
{
|
{
|
||||||
Id = quantity.Id,
|
Id = quantity.Id,
|
||||||
WarehouseId = quantity.WarehouseId,
|
WarehouseId = quantity.WarehouseId,
|
||||||
Name = req.Name,
|
Label = req.Label,
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(responseDto, ct);
|
@@ -1,12 +1,12 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Material;
|
namespace PyroFetes.Endpoints.Material;
|
||||||
public class DeleteMaterialRequest
|
public class DeleteMaterialRequest
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
public class DeleteMaterialEndpoint(AppDbContext appDbContext) : Endpoint<DeleteMaterialRequest>
|
public class DeleteMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteMaterialRequest>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -16,7 +16,7 @@ public class DeleteMaterialEndpoint(AppDbContext appDbContext) : Endpoint<Delete
|
|||||||
|
|
||||||
public override async Task HandleAsync(DeleteMaterialRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteMaterialRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Material? materialToDelete = await appDbContext
|
Models.Material? materialToDelete = await pyrofetesdbcontext
|
||||||
.Materials
|
.Materials
|
||||||
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -27,8 +27,8 @@ public class DeleteMaterialEndpoint(AppDbContext appDbContext) : Endpoint<Delete
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
appDbContext.Materials.Remove(materialToDelete);
|
pyrofetesdbcontext.Materials.Remove(materialToDelete);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
@@ -2,9 +2,9 @@ using API.DTO.Material.Response;
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Material;
|
namespace PyroFetes.Endpoints.Material;
|
||||||
|
|
||||||
public class GetAllMaterialsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest<List<GetMaterialDto>>
|
public class GetAllMaterialsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetMaterialDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,11 +14,11 @@ public class GetAllMaterialsEndpoint(AppDbContext appDbContext) : EndpointWithou
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetMaterialDto> responseDto = await appDbContext.Materials
|
List<GetMaterialDto> responseDto = await pyrofetesdbcontext.Materials
|
||||||
.Select(a => new GetMaterialDto
|
.Select(a => new GetMaterialDto
|
||||||
{
|
{
|
||||||
Id = a.Id,
|
Id = a.Id,
|
||||||
Name = a.Name,
|
Label = a.Name,
|
||||||
Quantity = a.Quantity,
|
Quantity = a.Quantity,
|
||||||
WarehouseId = a.WarehouseId,
|
WarehouseId = a.WarehouseId,
|
||||||
}
|
}
|
@@ -1,16 +1,15 @@
|
|||||||
using API.DTO.Material.Response;
|
using API.DTO.Material.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Material;
|
namespace PyroFetes.Endpoints.Material;
|
||||||
|
|
||||||
public class GetMaterialRequest
|
public class GetMaterialRequest
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetMaterialEndpoint(AppDbContext appDbContext) : Endpoint<GetMaterialRequest, GetMaterialDto>
|
public class GetMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetMaterialRequest, GetMaterialDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -20,7 +19,7 @@ public class GetMaterialEndpoint(AppDbContext appDbContext) : Endpoint<GetMateri
|
|||||||
|
|
||||||
public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Material? material = await appDbContext
|
Models.Material? material = await pyrofetesdbcontext
|
||||||
.Materials
|
.Materials
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ public class GetMaterialEndpoint(AppDbContext appDbContext) : Endpoint<GetMateri
|
|||||||
GetMaterialDto responseDto = new()
|
GetMaterialDto responseDto = new()
|
||||||
{
|
{
|
||||||
Id = material.Id,
|
Id = material.Id,
|
||||||
Name = material.Name,
|
Label = material.Name,
|
||||||
WarehouseId = material.WarehouseId,
|
WarehouseId = material.WarehouseId,
|
||||||
};
|
};
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(responseDto, ct);
|
@@ -1,12 +1,11 @@
|
|||||||
using API.DTO.Material.Request;
|
using API.DTO.Material.Request;
|
||||||
using API.DTO.Material.Response;
|
using API.DTO.Material.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Endpoints.Material;
|
namespace PyroFetes.Endpoints.Material;
|
||||||
|
|
||||||
public class UpdateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<UpdateMaterialDto, GetMaterialDto>
|
public class UpdateMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateMaterialDto, GetMaterialDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -16,7 +15,7 @@ public class UpdateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<Update
|
|||||||
|
|
||||||
public override async Task HandleAsync(UpdateMaterialDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateMaterialDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Material? materialToEdit = await appDbContext
|
Models.Material? materialToEdit = await pyrofetesdbcontext
|
||||||
.Materials
|
.Materials
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -27,14 +26,14 @@ public class UpdateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<Update
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
materialToEdit.Name = req.Name;
|
materialToEdit.Name = req.Label;
|
||||||
materialToEdit.WarehouseId = req.WarehouseId;
|
materialToEdit.WarehouseId = req.WarehouseId;
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
GetMaterialDto responseDto = new()
|
GetMaterialDto responseDto = new()
|
||||||
{
|
{
|
||||||
Id = req.Id,
|
Id = req.Id,
|
||||||
Name = req.Name,
|
Label = req.Label,
|
||||||
WarehouseId = req.WarehouseId,
|
WarehouseId = req.WarehouseId,
|
||||||
};
|
};
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(responseDto, ct);
|
Reference in New Issue
Block a user