DocSpace-buildtools/common/ASC.Core.Common/EF/Model/Tenant/DbTenant.cs

66 lines
2.1 KiB
C#
Raw Normal View History

2019-12-03 15:20:21 +00:00
using System;
using System.ComponentModel.DataAnnotations.Schema;
2020-04-27 16:59:52 +00:00
2019-12-03 15:20:21 +00:00
using ASC.Core.Tenants;
2020-04-27 16:59:52 +00:00
using Microsoft.EntityFrameworkCore;
2019-12-03 15:20:21 +00:00
namespace ASC.Core.Common.EF.Model
{
[Table("tenants_tenants")]
public class DbTenant
{
public int Id { get; set; }
public string Name { get; set; }
public string Alias { get; set; }
public string MappedDomain { get; set; }
public int Version { get; set; }
2020-07-15 08:38:00 +00:00
public DateTime? Version_Changed { get; set; }
[NotMapped]
public DateTime VersionChanged { get => Version_Changed ?? DateTime.MinValue; set => Version_Changed = value; }
2019-12-03 15:20:21 +00:00
public string Language { get; set; }
public string TimeZone { get; set; }
public string TrustedDomains { get; set; }
public TenantTrustedDomainsType TrustedDomainsEnabled { get; set; }
public TenantStatus Status { get; set; }
2020-07-15 08:38:00 +00:00
public DateTime? StatusChanged { get; set; }
//hack for DateTime?
[NotMapped]
public DateTime? StatusChangedHack { get { return StatusChanged; } set { StatusChanged = value; } }
2019-12-03 15:20:21 +00:00
public DateTime CreationDateTime { get; set; }
[Column("owner_id")]
public Guid OwnerId { get; set; }
public bool Public { get; set; }
public string PublicVisibleProducts { get; set; }
[Column("payment_id")]
public string PaymentId { get; set; }
public TenantIndustry? Industry { get; set; }
[Column("last_modified")]
public DateTime LastModified { get; set; }
public bool Spam { get; set; }
public bool Calls { get; set; }
public DbTenantPartner Partner { get; set; }
}
2020-04-27 16:59:52 +00:00
public static class DbTenantExtension
{
public static void AddDbTenant(this ModelBuilder modelBuilder)
{
modelBuilder.Entity<DbTenant>()
.HasOne(r => r.Partner)
.WithOne(r => r.Tenant)
.HasForeignKey<DbTenantPartner>(r => new { r.TenantId })
.HasPrincipalKey<DbTenant>(r => new { r.Id });
}
}
2019-12-03 15:20:21 +00:00
}