midoking

order.cs

Apr 30th, 2023
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using MVC_Project.Models.Identity;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4.  
  5. namespace MVC_Project.Models.Order
  6. {
  7.     public enum OrderStatus
  8.     {
  9.         PendingPayment,
  10.         Failed,
  11.         Processing,
  12.         Completed,
  13.         OnHold,
  14.         Cancelled,
  15.         Refunded
  16.     }
  17.     public enum PaymentMethod
  18.     {
  19.         Paypal
  20.     }
  21.     public class Order
  22.     {
  23.         public int Id { get; set; }
  24.  
  25.         [ForeignKey("Account")]
  26.         [Required]
  27.         public required int CustomerId { get; set; }
  28.  
  29.         [ForeignKey("Address")]
  30.         [Required]
  31.         public required int AddressId { get; set; }
  32.  
  33.         [ForeignKey("Cart")]
  34.         [Required]
  35.         public required int CartId { get; set; }
  36.  
  37.         [EnumDataType(typeof(OrderStatus))]
  38.         public OrderStatus? OrderStatus { get; set; }
  39.  
  40.         [DataType(DataType.Currency)]
  41.         public required double TotalPaid { get; set; }
  42.  
  43.         [EnumDataType(typeof(PaymentMethod))]
  44.         public required PaymentMethod PaymentMethod { get; set; }
  45.  
  46.         [ForeignKey("Invoice")]
  47.         public int? InvoiceId { get; set; }
  48.  
  49.         public virtual Invoice? Invoice { get; set; }
  50.         public virtual Address? Address { get; set; }
  51.         public virtual Account? Customer { get; set; }
  52.         public virtual Cart.Cart? Cart { get; set; }
  53.     }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment