DocSpace-client/common/ASC.Core.Common/EF/Model/Tenant/DbQuota.cs

149 lines
5.2 KiB
C#
Raw Normal View History

2020-09-06 22:49:03 +00:00
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
2020-08-21 02:34:37 +00:00
using System.ComponentModel.DataAnnotations;
2019-12-02 09:12:16 +00:00
using System.ComponentModel.DataAnnotations.Schema;
namespace ASC.Core.Common.EF
{
[Table("tenants_quota")]
2019-12-17 13:01:59 +00:00
public class DbQuota : BaseEntity
2019-12-02 09:12:16 +00:00
{
[Key]
public int Tenant { get; set; }
public string Name { get; set; }
public string Description { get; set; }
[Column("max_file_size")]
public long MaxFileSize { get; set; }
[Column("max_total_size")]
public long MaxTotalSize { get; set; }
[Column("active_users")]
public int ActiveUsers { get; set; }
public string Features { get; set; }
public decimal Price { get; set; }
public decimal Price2 { get; set; }
[Column("avangate_id")]
public string AvangateId { get; set; }
public bool Visible { get; set; }
2019-12-17 13:01:59 +00:00
2020-02-21 12:38:04 +00:00
public override object[] GetKeys()
2019-12-17 13:01:59 +00:00
{
return new object[] { Tenant };
}
2019-12-02 09:12:16 +00:00
}
2020-08-21 02:34:37 +00:00
public static class DbQuotaExtension
{
2020-09-06 22:49:03 +00:00
public static ModelBuilderWrapper AddDbQuota(this ModelBuilderWrapper modelBuilder)
{
modelBuilder
.Add(MySqlAddDbQuota, Provider.MySql)
.Add(PgSqlAddDbQuota, Provider.Postrge);
return modelBuilder;
}
public static void MySqlAddDbQuota(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<DbQuota>(entity =>
{
entity.HasKey(e => e.Tenant)
.HasName("PRIMARY");
entity.ToTable("tenants_quota");
entity.Property(e => e.Tenant).HasColumnName("tenant");
entity.Property(e => e.ActiveUsers).HasColumnName("active_users");
entity.Property(e => e.AvangateId)
.HasColumnName("avangate_id")
.HasColumnType("varchar(128)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.Description)
.HasColumnName("description")
.HasColumnType("varchar(128)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.Features)
.HasColumnName("features")
.HasColumnType("text")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.MaxFileSize).HasColumnName("max_file_size");
entity.Property(e => e.MaxTotalSize).HasColumnName("max_total_size");
entity.Property(e => e.Name)
.HasColumnName("name")
.HasColumnType("varchar(128)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.Price)
.HasColumnName("price")
.HasColumnType("decimal(10,2)");
entity.Property(e => e.Price2)
.HasColumnName("price2")
.HasColumnType("decimal(10,2)");
entity.Property(e => e.Visible).HasColumnName("visible");
});
}
2020-09-06 22:49:03 +00:00
public static void PgSqlAddDbQuota(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<DbQuota>(entity =>
{
entity.HasNoKey();
entity.ToTable("tenants_quota", "onlyoffice");
entity.Property(e => e.ActiveUsers).HasColumnName("active_users");
entity.Property(e => e.AvangateId)
.HasColumnName("avangate_id")
.HasMaxLength(128)
.HasDefaultValueSql("NULL::character varying");
entity.Property(e => e.Description)
.HasColumnName("description")
.HasColumnType("character varying");
entity.Property(e => e.Features).HasColumnName("features");
entity.Property(e => e.MaxFileSize)
.HasColumnName("max_file_size")
.HasDefaultValueSql("'0'::bigint");
entity.Property(e => e.MaxTotalSize)
.HasColumnName("max_total_size")
.HasDefaultValueSql("'0'::bigint");
entity.Property(e => e.Name)
.HasColumnName("name")
.HasColumnType("character varying");
entity.Property(e => e.Price)
.HasColumnName("price")
.HasColumnType("numeric(10,2)")
.HasDefaultValueSql("0.00");
entity.Property(e => e.Price2)
.HasColumnName("price2")
.HasColumnType("numeric(10,2)")
.HasDefaultValueSql("0.00");
entity.Property(e => e.Tenant).HasColumnName("tenant");
entity.Property(e => e.Visible).HasColumnName("visible");
});
}
}
2019-12-02 09:12:16 +00:00
}