Changed whole project structure (split client and server into separat projects)
This commit is contained in:
40
ReallifeGamemode.Server/Entities/UserVehicle.cs
Normal file
40
ReallifeGamemode.Server/Entities/UserVehicle.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using reallife_gamemode.Server.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Entities UserVehicle (UserVehicle.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
[Table("UserVehicles")]
|
||||
public class UserVehicle : ServerVehicle
|
||||
{
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Spieler Fahrzeug | Besitzer: " + GetOwner().Name;
|
||||
}
|
||||
|
||||
public User GetOwner(DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.Id == UserId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.Id == UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user