با سلام خدمت استاد مدائنی عزیز و همه دوستان و همدوره ای های گرامی
بنده با کمی تاخیر تحلیل خودم از جدول محصولات و جداول مربوط به آن را خدمت شما عزیزان به اشتراک میگذارم به امید اینکه ذره ای برای راهنمایی شما کافی باشد
تصویر دیاگرام و کلاس های جداول :
public class Product:BaseEntity
{
public int CategoryId { get; set; }
[ForeignKey("CategoryId")]
public Category Category { get; set; }
public int BrandId { get; set; }
[ForeignKey("BrandId")]
public Brand Brand { get; set; }
public string NameFa { get; set; }
public string NameEn { get; set; }
public string? ShortDescription { get; set; }
public string FullDescription { get; set; }
public string Slug { get; set; }
public string Barcode { get; set; }
public string MainImage { get; set; }
public string? Review { get; set; }
public string? DetailReview { get; set; }
public bool IsActive { get; set; } = true;
public string ExpertReview { get; set; } // بررسی تخصصی
public decimal Price { get; set; } // قیمت فعلی
public decimal? OldPrice { get; set; } // قیمت قبلی (برای نمایش تخفیف)
public int? DiscountPercent { get; set; } // درصد تخفیف
public int MinimumStockAlert { get; set; } = 5; // هشدار موجودی کم
public string Sku { get; set; } // شناسه کالا (SKU)
public int ViewCount { get; set; } // تعداد بازدید
public decimal AverageRating { get; set; } // میانگین امتیاز
public int RatingCount { get; set; } // تعداد امتیاز دهندگان
public int SuggestedCount { get; set; } // تعداد پیشنهاد کنندگان
public int NotSuggestedCount { get; set; } // تعداد عدم پیشنهاد
public virtual ICollection<ProductImage> Images { get; set; } = new List<ProductImage>();
public virtual ICollection<ProductVariant> Variants { get; set; } = new List<ProductVariant>();
public virtual ICollection<ProductSpecification> Specifications { get; set; } = new List<ProductSpecification>();
public virtual ICollection<ProductReview> Reviews { get; set; } = new List<ProductReview>();
public virtual ICollection<ProductQuestion> Questions { get; set; } = new List<ProductQuestion>();
public virtual ICollection<ProductSupplier> Suppliers { get; set; } = new List<ProductSupplier>();
public virtual ICollection<ProductWishlist> Wishlists { get; set; } = new List<ProductWishlist>();
public virtual ICollection<ProductDiscount> Discounts { get; set; } = new List<ProductDiscount>();
}
public class Supplier:BaseEntity
{
// ==================== جدول فروشندگان ====================
[Required]
[MaxLength(150)]
public string Name { get; set; }
public string LogoUrl { get; set; }
public decimal SatisfactionRate { get; set; } // درصد رضایت
public string PerformanceLabel { get; set; } // "عالی", "خوب" و ...
public string Description { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public string Address { get; set; }
public bool IsActive { get; set; } = true;
public ICollection<ProductSupplier> ProductSuppliers { get; set; } = new List<ProductSupplier>();
}
public class ProductVariant:BaseEntity
{
// ==================== جدول تنوعهای محصول (رنگ، سایز و ...) ====================
[Required]
public int ProductId { get; set; }
[Required]
[MaxLength(50)]
public string VariantType { get; set; } // "رنگ", "سایز", "ظرفیت" و ...
[Required]
[MaxLength(50)]
public string VariantValue { get; set; } // "آبی", "Large", "128GB" و ...
[MaxLength(20)]
public string ColorCode { get; set; } // کد رنگ HEX برای نمایش
public decimal? PriceAdjustment { get; set; } // تغییر قیمت نسبت به محصول اصلی
public int StockQuantity { get; set; }
public bool IsActive { get; set; } = true;
[ForeignKey("ProductId")]
public Product Product { get; set; }
}
public class ProductSupplier:BaseEntity
{
// ==================== جدول فروشندگان محصول ====================
[Required]
public int ProductId { get; set; }
[Required]
public int SupplierId { get; set; }
public decimal Price { get; set; }
public int StockQuantity { get; set; }
public string Warranty { get; set; } // گارانتی
public string ShippingMethod { get; set; } // روش ارسال
public string Condition { get; set; } // شرایط
public bool IsActive { get; set; } = true;
public DateTime CreatedAt { get; set; } = DateTime.Now;
[ForeignKey("ProductId")]
public Product Product { get; set; }
[ForeignKey("SupplierId")]
public Supplier Supplier { get; set; }
}