migrating to .NET Core 2.0
This commit is contained in:
26
SharedLibraryCore/Database/Models/EFAlias.cs
Normal file
26
SharedLibraryCore/Database/Models/EFAlias.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace SharedLibraryCore.Database.Models
|
||||
{
|
||||
public class EFAlias : SharedEntity
|
||||
{
|
||||
[Key]
|
||||
public int AliasId { get; set; }
|
||||
[Required]
|
||||
public int LinkId { get; set; }
|
||||
[ForeignKey("LinkId")]
|
||||
public virtual EFAliasLink Link { get; set; }
|
||||
// [Index("IX_IPandName", 0, IsUnique = true)]
|
||||
//[MaxLength(24)]
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
// [Index("IX_IPandName", 1, IsUnique = true)]
|
||||
// [MaxLength(24)]
|
||||
[Required]
|
||||
public int IPAddress { get; set; }
|
||||
[Required]
|
||||
public DateTime DateAdded { get; set; }
|
||||
}
|
||||
}
|
21
SharedLibraryCore/Database/Models/EFAliasLink.cs
Normal file
21
SharedLibraryCore/Database/Models/EFAliasLink.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
|
||||
namespace SharedLibraryCore.Database.Models
|
||||
{
|
||||
public class EFAliasLink : SharedEntity
|
||||
{
|
||||
[Key]
|
||||
public int AliasLinkId { get; set; }
|
||||
public virtual ICollection<EFAlias> Children { get; set; }
|
||||
public virtual ICollection<EFPenalty> ReceivedPenalties { get; set; }
|
||||
|
||||
public EFAliasLink()
|
||||
{
|
||||
Children = new List<EFAlias>();
|
||||
ReceivedPenalties = new List<EFPenalty>();
|
||||
}
|
||||
}
|
||||
}
|
63
SharedLibraryCore/Database/Models/EFClient.cs
Normal file
63
SharedLibraryCore/Database/Models/EFClient.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace SharedLibraryCore.Database.Models
|
||||
{
|
||||
public class EFClient : SharedEntity
|
||||
{
|
||||
[Key]
|
||||
public int ClientId { get; set; }
|
||||
public long NetworkId { get; set; }
|
||||
[Required]
|
||||
public int Connections { get; set; }
|
||||
[Required]
|
||||
// in seconds
|
||||
public int TotalConnectionTime { get; set; }
|
||||
[Required]
|
||||
public DateTime FirstConnection { get; set; }
|
||||
[Required]
|
||||
public DateTime LastConnection { get; set; }
|
||||
public bool Masked { get; set; }
|
||||
[Required]
|
||||
public int AliasLinkId { get; set; }
|
||||
[ForeignKey("AliasLinkId")]
|
||||
public virtual EFAliasLink AliasLink { get; set; }
|
||||
[Required]
|
||||
public Objects.Player.Permission Level { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CurrentAliasId { get; set; }
|
||||
[ForeignKey("CurrentAliasId")]
|
||||
public virtual EFAlias CurrentAlias { get; set; }
|
||||
|
||||
public string Password { get; set; }
|
||||
public string PasswordSalt { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public virtual string Name
|
||||
{
|
||||
get { return CurrentAlias.Name; }
|
||||
set { }
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual int IPAddress
|
||||
{
|
||||
get { return CurrentAlias.IPAddress; }
|
||||
set { }
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public string IPAddressString => new System.Net.IPAddress(BitConverter.GetBytes(IPAddress)).ToString();
|
||||
|
||||
public virtual ICollection<EFPenalty> ReceivedPenalties { get; set; }
|
||||
public virtual ICollection<EFPenalty> AdministeredPenalties { get; set; }
|
||||
|
||||
public EFClient()
|
||||
{
|
||||
ReceivedPenalties = new List<EFPenalty>();
|
||||
AdministeredPenalties = new List<EFPenalty>();
|
||||
}
|
||||
}
|
||||
}
|
35
SharedLibraryCore/Database/Models/EFPenalty.cs
Normal file
35
SharedLibraryCore/Database/Models/EFPenalty.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibraryCore.Database.Models
|
||||
{
|
||||
public class EFPenalty : SharedEntity
|
||||
{
|
||||
[Key]
|
||||
public int PenaltyId { get; set; }
|
||||
[Required]
|
||||
public int LinkId { get; set; }
|
||||
[ForeignKey("LinkId")]
|
||||
public virtual EFAliasLink Link { get; set; }
|
||||
[Required]
|
||||
public int OffenderId { get; set; }
|
||||
[ForeignKey("OffenderId")]
|
||||
public virtual EFClient Offender { get; set; }
|
||||
[Required]
|
||||
public int PunisherId { get; set; }
|
||||
[ForeignKey("PunisherId")]
|
||||
public virtual EFClient Punisher { get; set; }
|
||||
[Required]
|
||||
public DateTime When { get; set; }
|
||||
[Required]
|
||||
public DateTime Expires { get; set; }
|
||||
[Required]
|
||||
public string Offense { get; set; }
|
||||
public Objects.Penalty.PenaltyType Type { get; set; }
|
||||
}
|
||||
}
|
13
SharedLibraryCore/Database/Models/SharedEntity.cs
Normal file
13
SharedLibraryCore/Database/Models/SharedEntity.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibraryCore.Database.Models
|
||||
{
|
||||
public class SharedEntity
|
||||
{
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user