Add base product DbEntities and domain Entities
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Printbase.Infrastructure.DbEntities.Products;
|
||||
|
||||
[Table("Products")]
|
||||
public class ProductDbEntity
|
||||
{
|
||||
[Key, Required]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[MaxLength(50), Required]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,2)")]
|
||||
public decimal? Discount { get; set; }
|
||||
|
||||
[Required]
|
||||
public Guid TypeId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TypeId)), Required]
|
||||
public required ProductTypeDbEntity Type { get; set; }
|
||||
|
||||
[InverseProperty(nameof(ProductVariantDbEntity.Product)), Required]
|
||||
public required ICollection<ProductVariantDbEntity> Variants { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Printbase.Infrastructure.DbEntities.Products;
|
||||
|
||||
[Table("ProductGroups")]
|
||||
public class ProductGroupDbEntity
|
||||
{
|
||||
[Key, Required]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[MaxLength(50), Required]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[MaxLength(255)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[InverseProperty(nameof(ProductTypeDbEntity.Group)), Required]
|
||||
public required ICollection<ProductTypeDbEntity> Types { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Printbase.Infrastructure.DbEntities.Products;
|
||||
|
||||
[Table("ProductTypes")]
|
||||
public class ProductTypeDbEntity
|
||||
{
|
||||
[Key, Required]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[MaxLength(50), Required]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[MaxLength(255)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Required]
|
||||
public Guid GroupId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(GroupId)), Required]
|
||||
public required ProductGroupDbEntity Group { get; set; }
|
||||
|
||||
[InverseProperty(nameof(ProductDbEntity.Type))]
|
||||
public ICollection<ProductDbEntity>? Products { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Printbase.Infrastructure.DbEntities.Products;
|
||||
|
||||
[Table("ProductVariants")]
|
||||
public class ProductVariantDbEntity
|
||||
{
|
||||
[Key, Required]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public Guid ProductId { get; set; }
|
||||
|
||||
[MaxLength(50)]
|
||||
public string? Color { get; set; }
|
||||
|
||||
[MaxLength(20)]
|
||||
public string? Size { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,2)"), Required]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,2)")]
|
||||
public decimal? Discount { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Stock { get; set; }
|
||||
|
||||
[ForeignKey(nameof(ProductId)), Required]
|
||||
public required ProductDbEntity Product { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user