Fixed EF error, edit commands, fix faction broadcast

This commit is contained in:
hydrant
2018-09-23 15:59:40 +02:00
parent 4631f4bb75
commit bba0f7206c
6 changed files with 82 additions and 27 deletions

View File

@@ -1,8 +1,10 @@
using reallife_gamemode.Server.Util;
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;
/**
@@ -31,8 +33,24 @@ namespace reallife_gamemode.Server.Entities
[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);
}
}
}
}