【发布时间】:2018-03-23 03:12:43
【问题描述】:
我正在使用 asp.net 身份,并且我有一个名为 Products 的类,但我希望能够将产品链接到用户,我将如何添加一个存储活动登录用户的列针对产品的身份。顺便说一句,我主要使用脚手架来制作我的杂物,所以想要一个带有这个的方式比较表。
Obv 我正在使用身份核心,只需要不知道如何添加正确的字段来让它存储用户 ID。
我还需要做的是管理员组中的任何人,然后它会显示所有产品,但当它是用户时,它只会显示由他们创建的产品?
public class Products
{
[Key]
public int ProductId { get; set; }
public string ProductName { get; set; }
public string ShotDescription { get; set; }
public decimal OldPrice { get; set; }
public decimal NewPrice { get; set; }
public bool DisableBuyButton { get; set; }
public bool DisableWishListButton { get; set; }
public bool ShowForPrice { get; set; }
public bool NotReturnable { get; set; }
public int MinimumCartQty { get; set; }
public int MaximumCartQty { get; set; }
public string SKU { get; set; }
public bool ShippingEnabled { get; set; }
public decimal Weight { get; set; }
public decimal Length { get; set; }
public decimal Width { get; set; }
public decimal Height { get; set; }
public string Categories { get; set; }
public string ManufacturerPartNumber { get; set; }
public DateTime AvailableDate { get; set; }
public DateTime AvailableEndDate { get; set; }
public string AdminComment { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime UpdatedOn { get; set; }
public Boolean DisplayAvailability { get; set; }
public DateTime ExpectedDateBackOnStock { get; set; }
public bool IsOnBackOrder { get; set; }
public int Warehouse { get; set; }
public int BinNumber { get; set; }
public int IlseNumber { get; set; }
public bool IsGiftCard { get; set; }
public bool IsDownloadableProduct { get; set; }
public bool IsRental { get; set; }
public string SeoDescription { get; set; }
public int Stock { get; set; }
public int PropertyImageId { get; set; }
}
【问题讨论】:
-
每个产品只有一个userid还是多个?
-
@ecKO 其允许程序根据当前用户过滤到一个用户可以拥有多个产品
标签: c# asp.net entity-framework-core ef-core-2.0