前面已建立四個Role
後續建立分店,來辨別分店員工與主管。
建立步驟
public class Store
{
public int Id { get; set; }
[Required]
public string Name { get; set; }
public string? Address { get; set; }
public string? City { get; set; }
public string? PhoneNumber { get; set; }
public string? Description { get; set; }
}
修改ApplicationDbContext.cs
寫入預設資料
modelBuilder.Entity<Store>().HasData(
new Store { Id = 1, Name = "台北信義店", Address = "台北市信義區六段55號", City = "台北市", PhoneNumber = "0980001112", Description = "學生Shopping勝地。" },
new Store { Id = 2, Name = "台中一中店", Address = "台中市中區和平路66號", City = "台中市", PhoneNumber = "0955511111", Description = "熱鬧繁華的商圈,豐富整體氛圍。" },
new Store { Id = 3, Name = "台南安平店", Address = "台南市安平區中山路77號", City = "台南市", PhoneNumber = "0933322222", Description = "交通方便易於購物。" }
);
建立Repository、IRepository
複製Category的Repository、IRepository:
修改UnitOfWork、IUnitOfWork
打開UnitOfWork、IUnitOfWork: