2023-05-26 16:49:32 +02:00
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2020-06-27 14:55:16 +02:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2017-09-13 08:47:34 +02:00
|
|
|
|
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
2017-10-27 10:53:04 +02:00
|
|
|
public class UserStore
|
|
|
|
{
|
2020-12-28 21:57:21 +01:00
|
|
|
public string ApplicationUserId { get; set; }
|
|
|
|
public ApplicationUser ApplicationUser { get; set; }
|
|
|
|
|
|
|
|
public string StoreDataId { get; set; }
|
|
|
|
public StoreData StoreData { get; set; }
|
2023-05-26 16:49:32 +02:00
|
|
|
[Column("Role")]
|
|
|
|
public string StoreRoleId { get; set; }
|
|
|
|
public StoreRole StoreRole { get; set; }
|
|
|
|
|
2017-09-13 08:47:34 +02:00
|
|
|
|
2020-06-27 14:55:16 +02:00
|
|
|
|
|
|
|
internal static void OnModelCreating(ModelBuilder builder)
|
|
|
|
{
|
|
|
|
builder.Entity<UserStore>()
|
|
|
|
.HasOne(o => o.StoreData)
|
|
|
|
.WithMany(i => i.UserStores).OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.Entity<UserStore>()
|
|
|
|
.HasKey(t => new
|
|
|
|
{
|
|
|
|
t.ApplicationUserId,
|
|
|
|
t.StoreDataId
|
|
|
|
});
|
|
|
|
builder.Entity<UserStore>()
|
|
|
|
.HasOne(pt => pt.ApplicationUser)
|
|
|
|
.WithMany(p => p.UserStores)
|
|
|
|
.HasForeignKey(pt => pt.ApplicationUserId);
|
|
|
|
|
|
|
|
builder.Entity<UserStore>()
|
|
|
|
.HasOne(pt => pt.StoreData)
|
|
|
|
.WithMany(t => t.UserStores)
|
|
|
|
.HasForeignKey(pt => pt.StoreDataId);
|
2023-05-26 16:49:32 +02:00
|
|
|
|
|
|
|
builder.Entity<UserStore>().HasOne(e => e.StoreRole)
|
|
|
|
.WithMany(role => role.Users)
|
|
|
|
.HasForeignKey(e => e.StoreRoleId);
|
2020-06-27 14:55:16 +02:00
|
|
|
}
|
2017-10-27 10:53:04 +02:00
|
|
|
}
|
2017-09-13 08:47:34 +02:00
|
|
|
}
|