ForeignKey

This commit is contained in:
Игорь Гордеев 2024-04-30 21:59:22 +04:00
parent e2dd3b3b4f
commit 3b332d1fe9
4 changed files with 8 additions and 5 deletions

View File

@ -18,7 +18,7 @@ namespace ElectronicsShopDataBaseImplement.Models
public int ID { get; set; }
[Required]
public double Sum { get; set; }
[Required]
[ForeignKey("UserID")]
public int UserID { get; set; }
[Required]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -11,10 +12,10 @@ namespace ElectronicsShopDataBaseImplement.Models
{
public int ID { get; set; }
[Required]
[ForeignKey("OrderID")]
public int OrdersID { get; set; }
[Required]
[ForeignKey("ProductID")]
public int ProductID { get; set; }
[Required]

View File

@ -4,6 +4,7 @@ using ElectronicsShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -17,7 +18,7 @@ namespace ElectronicsShopDataBaseImplement.Models
public string ProductName { get; set; }=string.Empty;
[Required]
public double Price { get; set; }
[Required]
[ForeignKey("CategoryID")]
public int CategoryID { get; set; }
public static Product? Create(ProductBindingModel? model)

View File

@ -4,6 +4,7 @@ using ElectronicsShopDataModels;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -25,7 +26,7 @@ namespace ElectronicsShopDataBaseImplement.Models
public string Login { get; set; } = string.Empty;
[Required]
public string Email { get; set; } = string.Empty;
[Required]
[ForeignKey("RoleID")]
public int RoleID { get; set; }
public static User? Create(UserBindingModel model)