forked from sanchezvem/pyrofetes-backend
MAJ update movement
This commit is contained in:
@@ -1,19 +1,23 @@
|
|||||||
// Définition de l'espace de noms pour les DTO utilisés dans les requêtes liées aux mouvements
|
using PyroFetes.Models;
|
||||||
namespace API.DTO.Movement.Request
|
|
||||||
|
// Assure-toi d'importer tes enums
|
||||||
|
|
||||||
|
namespace PyroFetes.DTO.Movement.Request
|
||||||
{
|
{
|
||||||
// DTO utilisé pour créer un nouveau mouvement
|
|
||||||
public class CreateMovementDto
|
public class CreateMovementDto
|
||||||
{
|
{
|
||||||
// Date à laquelle le mouvement est enregistré
|
public int ProductId { get; set; }
|
||||||
public DateTime Date { 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; }
|
public DateTime Start { get; set; }
|
||||||
|
|
||||||
// Date et heure d'arrivée prévue du mouvement
|
|
||||||
public DateTime Arrival { get; set; }
|
public DateTime Arrival { get; set; }
|
||||||
|
|
||||||
// Quantité de matériaux ou objets impliqués dans le mouvement
|
public int? SourceWarehouseId { get; set; }
|
||||||
public int Quantity { get; set; }
|
public int? DestinationWarehouseId { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,5 @@ namespace PyroFetes.DTO.Product.Request
|
|||||||
|
|
||||||
// Liste des entrepôts liés au produit venant du DTO CreateProductWarehouseDto
|
// Liste des entrepôts liés au produit venant du DTO CreateProductWarehouseDto
|
||||||
public List<CreateProductWarehouseDto>? Warehouses { get; set; }
|
public List<CreateProductWarehouseDto>? Warehouses { get; set; }
|
||||||
|
|
||||||
public int MovementId { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using API.DTO.Movement.Request;
|
using API.DTO.Movement.Request;
|
||||||
using API.DTO.Movement.Response;
|
using API.DTO.Movement.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
using PyroFetes.DTO.Movement.Request;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Movement;
|
namespace PyroFetes.Endpoints.Movement;
|
||||||
|
|
||||||
@@ -17,9 +18,11 @@ public class CreateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
Models.Movement movement = new ()
|
Models.Movement movement = new ()
|
||||||
{
|
{
|
||||||
Date = req.Date,
|
Date = req.Date,
|
||||||
|
ProductId = req.ProductId,
|
||||||
Start = req.Start,
|
Start = req.Start,
|
||||||
Arrival = req.Arrival,
|
Arrival = req.Arrival,
|
||||||
Quantity = req.Quantity
|
Quantity = req.Quantity,
|
||||||
|
Type = req.Type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pyrofetesdbcontext.Movements.Add(movement);
|
pyrofetesdbcontext.Movements.Add(movement);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class CreateProductEndpoint(PyroFetesDbContext db)
|
|||||||
Link = req.Link!,
|
Link = req.Link!,
|
||||||
ProductCategoryId = req.ProductCategoryId,
|
ProductCategoryId = req.ProductCategoryId,
|
||||||
ClassificationId = req.ClassificationId,
|
ClassificationId = req.ClassificationId,
|
||||||
MovementId = req.MovementId
|
|
||||||
};
|
};
|
||||||
|
|
||||||
db.Products.Add(product);
|
db.Products.Add(product);
|
||||||
|
|||||||
@@ -2,18 +2,42 @@
|
|||||||
|
|
||||||
namespace PyroFetes.Models;
|
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
|
public class Movement
|
||||||
{
|
{
|
||||||
[Key] public int Id { get; set; }
|
[Key]
|
||||||
[Required] public DateTime Date { get; set; }
|
public int Id { 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; }
|
[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 int? SourceWarehouseId { get; set; }
|
||||||
public Warehouse? SourceWarehouse { get; set; }
|
public Warehouse? SourceWarehouse { get; set; }
|
||||||
|
|
||||||
public int? DestinationWarehouseId { get; set; }
|
public int? DestinationWarehouseId { get; set; }
|
||||||
public Warehouse? DestinationWarehouse { get; set; }
|
public Warehouse? DestinationWarehouse { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(500)]
|
||||||
|
public string? Comment { get; set; }
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,9 @@ namespace PyroFetes.Models
|
|||||||
[Required, MaxLength(100)] public string? ApprovalNumber { get; set; }
|
[Required, MaxLength(100)] public string? ApprovalNumber { get; set; }
|
||||||
[Required] public decimal Weight { get; set; }
|
[Required] public decimal Weight { get; set; }
|
||||||
[Required] public decimal Nec { get; set; }
|
[Required] public decimal Nec { get; set; }
|
||||||
[Required] public string? Image { get; set; }
|
public string? Image { get; set; }
|
||||||
[Required, MaxLength(200)] public string? Link { get; set; }
|
[MaxLength(200)] public string? Link { get; set; }
|
||||||
[Required] public int MinimalQuantity { get; set; }
|
public int MinimalQuantity { get; set; }
|
||||||
|
|
||||||
// Relations
|
// Relations
|
||||||
[Required] public int ClassificationId { get; set; }
|
[Required] public int ClassificationId { get; set; }
|
||||||
@@ -23,8 +23,7 @@ namespace PyroFetes.Models
|
|||||||
[Required] public int ProductCategoryId { get; set; }
|
[Required] public int ProductCategoryId { get; set; }
|
||||||
public ProductCategory? ProductCategory { get; set; }
|
public ProductCategory? ProductCategory { get; set; }
|
||||||
|
|
||||||
[Required] public int MovementId {get; set;}
|
public List<Movement>? Movements { get; set; }
|
||||||
public Movement? Movement {get; set;}
|
|
||||||
|
|
||||||
public List<ProductDelivery>? ProductDeliveries { get; set; }
|
public List<ProductDelivery>? ProductDeliveries { get; set; }
|
||||||
public List<Brand>? Brands { get; set; }
|
public List<Brand>? Brands { get; set; }
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ using FastEndpoints.Swagger;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes;
|
using PyroFetes;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Services
|
builder.Services
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<RollForward>Major</RollForward>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -22,8 +23,4 @@
|
|||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Migrations\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ namespace PyroFetes;
|
|||||||
|
|
||||||
public class PyroFetesDbContext : DbContext
|
public class PyroFetesDbContext : DbContext
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// Entities
|
// Entities
|
||||||
public DbSet<Availability> Availabilities { get; set; }
|
public DbSet<Availability> Availabilities { get; set; }
|
||||||
public DbSet<Brand> Brands { get; set; }
|
public DbSet<Brand> Brands { get; set; }
|
||||||
@@ -55,7 +57,7 @@ public class PyroFetesDbContext : DbContext
|
|||||||
{
|
{
|
||||||
string connectionString =
|
string connectionString =
|
||||||
"Server=romaric-thibault.fr;" +
|
"Server=romaric-thibault.fr;" +
|
||||||
"Database=Pyromana;" +
|
"Database=PyroMana;" +
|
||||||
"User Id=matheo;" +
|
"User Id=matheo;" +
|
||||||
"Password=Onto9-Cage-Afflicted;" +
|
"Password=Onto9-Cage-Afflicted;" +
|
||||||
"TrustServerCertificate=true;";
|
"TrustServerCertificate=true;";
|
||||||
|
|||||||
Reference in New Issue
Block a user