MAJ update movement

This commit is contained in:
2026-04-21 10:27:00 +02:00
parent 2af5c1e015
commit 1dcb3c35f2
9 changed files with 66 additions and 38 deletions

View File

@@ -1,19 +1,23 @@
// Définition de l'espace de noms pour les DTO utilisés dans les requêtes liées aux mouvements
namespace API.DTO.Movement.Request
using PyroFetes.Models;
// Assure-toi d'importer tes enums
namespace PyroFetes.DTO.Movement.Request
{
// DTO utilisé pour créer un nouveau mouvement
public class CreateMovementDto
{
// Date à laquelle le mouvement est enregistré
public DateTime Date { get; set; }
public int ProductId { get; set; }
// Date et heure de début du mouvement
public MovementType Type { get; set; }
public int Quantity { get; set; }
public DateTime Date { get; set; } = DateTime.Now;
public DateTime Start { get; set; }
// Date et heure d'arrivée prévue du mouvement
public DateTime Arrival { get; set; }
// Quantité de matériaux ou objets impliqués dans le mouvement
public int Quantity { get; set; }
public int? SourceWarehouseId { get; set; }
public int? DestinationWarehouseId { get; set; }
}
}

View File

@@ -46,7 +46,5 @@ namespace PyroFetes.DTO.Product.Request
// Liste des entrepôts liés au produit venant du DTO CreateProductWarehouseDto
public List<CreateProductWarehouseDto>? Warehouses { get; set; }
public int MovementId { get; set; }
}
}

View File

@@ -1,6 +1,7 @@
using API.DTO.Movement.Request;
using API.DTO.Movement.Response;
using FastEndpoints;
using PyroFetes.DTO.Movement.Request;
namespace PyroFetes.Endpoints.Movement;
@@ -17,9 +18,11 @@ public class CreateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
Models.Movement movement = new ()
{
Date = req.Date,
ProductId = req.ProductId,
Start = req.Start,
Arrival = req.Arrival,
Quantity = req.Quantity
Quantity = req.Quantity,
Type = req.Type,
};
pyrofetesdbcontext.Movements.Add(movement);

View File

@@ -29,7 +29,6 @@ public class CreateProductEndpoint(PyroFetesDbContext db)
Link = req.Link!,
ProductCategoryId = req.ProductCategoryId,
ClassificationId = req.ClassificationId,
MovementId = req.MovementId
};
db.Products.Add(product);

View File

@@ -2,18 +2,42 @@
namespace PyroFetes.Models;
// 1. Définition des types possibles pour la logique métier
public enum MovementType
{
Entry, // Entrée (ex: Achat fournisseur)
Exit, // Sortie (ex: Vente, Casse)
Transfer, // Transfert entre deux entrepôts
Inventory // Ajustement manuel
}
public class Movement
{
[Key] public int Id { get; set; }
[Required] public DateTime Date { get; set; }
[Required] public DateTime Start {get; set;}
[Required] public DateTime Arrival {get; set;}
[Required] public int Quantity {get; set;}
public List<Product>? Products { get; set; }
public int? SourceWarehouseId {get; set;}
public Warehouse? SourceWarehouse {get; set;}
public int? DestinationWarehouseId {get; set;}
public Warehouse? DestinationWarehouse {get; set;}
[Key]
public int Id { get; set; }
[Required]
public DateTime Date { get; set; } = DateTime.Now;
public DateTime Start { get; set; }
public DateTime Arrival { get; set; }
[Required]
public int Quantity { get; set; }
[Required]
public MovementType Type { get; set; }
[Required]
public int ProductId { get; set; }
public Product? Product { get; set; }
public int? SourceWarehouseId { get; set; }
public Warehouse? SourceWarehouse { get; set; }
public int? DestinationWarehouseId { get; set; }
public Warehouse? DestinationWarehouse { get; set; }
[MaxLength(500)]
public string? Comment { get; set; }
}

View File

@@ -12,9 +12,9 @@ namespace PyroFetes.Models
[Required, MaxLength(100)] public string? ApprovalNumber { get; set; }
[Required] public decimal Weight { get; set; }
[Required] public decimal Nec { get; set; }
[Required] public string? Image { get; set; }
[Required, MaxLength(200)] public string? Link { get; set; }
[Required] public int MinimalQuantity { get; set; }
public string? Image { get; set; }
[MaxLength(200)] public string? Link { get; set; }
public int MinimalQuantity { get; set; }
// Relations
[Required] public int ClassificationId { get; set; }
@@ -23,8 +23,7 @@ namespace PyroFetes.Models
[Required] public int ProductCategoryId { get; set; }
public ProductCategory? ProductCategory { get; set; }
[Required] public int MovementId {get; set;}
public Movement? Movement {get; set;}
public List<Movement>? Movements { get; set; }
public List<ProductDelivery>? ProductDeliveries { get; set; }
public List<Brand>? Brands { get; set; }

View File

@@ -4,6 +4,8 @@ using FastEndpoints.Swagger;
using Microsoft.EntityFrameworkCore;
using PyroFetes;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services

View File

@@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RollForward>Major</RollForward>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
@@ -14,16 +15,12 @@
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.20">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.20" />
<PackageReference Include="PasswordGenerator" Version="2.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>

View File

@@ -6,6 +6,8 @@ namespace PyroFetes;
public class PyroFetesDbContext : DbContext
{
// Entities
public DbSet<Availability> Availabilities { get; set; }
public DbSet<Brand> Brands { get; set; }
@@ -55,7 +57,7 @@ public class PyroFetesDbContext : DbContext
{
string connectionString =
"Server=romaric-thibault.fr;" +
"Database=Pyromana;" +
"Database=PyroMana;" +
"User Id=matheo;" +
"Password=Onto9-Cage-Afflicted;" +
"TrustServerCertificate=true;";