using reallife_gamemode.Model; using reallife_gamemode.Server.Util; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; /** * @overview Life of German Reallife - Entities User (User.cs) * @author VegaZ, hydrant * @copyright (c) 2008 - 2018 Life of German */ namespace reallife_gamemode.Server.Entities { public class User { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } [StringLength(32)] public string Name { get; set; } [StringLength(32)] public string SocialClubName { get; set; } [StringLength(64)] public string Password { get; set; } public int LogUserId { get; set; } [Timestamp] public byte[] RegistrationDate { get; set; } [EmailAddress] [StringLength(64)] public string Email { get; set; } public AdminLevel AdminLevel { get; set; } public int? FactionId { get; set; } public Faction Faction { get; set; } public bool IsAdmin(AdminLevel level) => AdminLevel >= level; public Faction GetFaction(DatabaseContext context = null) { if(context == null) { using(context = new DatabaseContext()) { return context.Factions.FirstOrDefault(f => f.Id == FactionId); } } else { return context.Factions.FirstOrDefault(f => f.Id == FactionId); } } } }