main
| Rev | Line | |
|---|
| [dfe03b8] | 1 | using System;
|
|---|
| 2 | using System.ComponentModel.DataAnnotations;
|
|---|
| 3 | using System.ComponentModel.DataAnnotations.Schema;
|
|---|
| 4 |
|
|---|
| 5 | namespace StockMaster.Models
|
|---|
| 6 | {
|
|---|
| 7 | [Table("product", Schema = "stock_management")]
|
|---|
| 8 | public class Product
|
|---|
| 9 | {
|
|---|
| 10 | [Key]
|
|---|
| 11 | [Column("product_id")]
|
|---|
| 12 | public int ProductId { get; set; }
|
|---|
| 13 |
|
|---|
| 14 | [Required(ErrorMessage = "Product name is required")]
|
|---|
| 15 | [MaxLength(100)]
|
|---|
| 16 | [Column("name")]
|
|---|
| 17 | public string Name { get; set; }
|
|---|
| 18 |
|
|---|
| 19 | [Column("description")]
|
|---|
| 20 | public string Description { get; set; }
|
|---|
| 21 |
|
|---|
| 22 | [Required(ErrorMessage = "SKU is required")]
|
|---|
| 23 | [MaxLength(50)]
|
|---|
| 24 | [Column("sku")]
|
|---|
| 25 | public string Sku { get; set; }
|
|---|
| 26 |
|
|---|
| 27 | [Required(ErrorMessage = "Unit price is required")]
|
|---|
| 28 | [Range(0.01, double.MaxValue, ErrorMessage = "Unit price must be greater than 0")]
|
|---|
| 29 | [Column("unit_price")]
|
|---|
| 30 | public decimal UnitPrice { get; set; }
|
|---|
| 31 |
|
|---|
| 32 | [Column("reorder_level")]
|
|---|
| 33 | public int ReorderLevel { get; set; } = 10;
|
|---|
| 34 |
|
|---|
| 35 | [Column("category_id")]
|
|---|
| 36 | public int? CategoryId { get; set; }
|
|---|
| 37 |
|
|---|
| 38 | [ForeignKey("CategoryId")]
|
|---|
| 39 | public Category Category { get; set; }
|
|---|
| 40 |
|
|---|
| 41 | [Column("supplier_id")]
|
|---|
| 42 | public int? SupplierId { get; set; }
|
|---|
| 43 |
|
|---|
| 44 | [ForeignKey("SupplierId")]
|
|---|
| 45 | public Supplier Supplier { get; set; }
|
|---|
| 46 |
|
|---|
| 47 | [Column("is_active")]
|
|---|
| 48 | public bool IsActive { get; set; } = true;
|
|---|
| 49 |
|
|---|
| 50 | [Column("created_at")]
|
|---|
| 51 | public DateTime CreatedAt { get; set; } = DateTime.Now;
|
|---|
| 52 | }
|
|---|
| 53 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.