44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using GTANetworkAPI;
|
|
using ReallifeGamemode.Server.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace ReallifeGamemode.Server.Entities
|
|
{
|
|
public class House
|
|
{
|
|
[Key]
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public int Id { get; set; }
|
|
|
|
public string Type { get; set; }
|
|
|
|
public int Price { get; set; }
|
|
|
|
public float X { get; set; }
|
|
public float Y { get; set; }
|
|
public float Z { get; set; }
|
|
|
|
[NotMapped]
|
|
public Vector3 Position => new Vector3(X, Y, Z);
|
|
|
|
[ForeignKey("User")]
|
|
public int? UserId { get; set; }
|
|
public User User { get; set; }
|
|
|
|
[NotMapped]
|
|
public Client Owner
|
|
{
|
|
get
|
|
{
|
|
using (var dbContext = new DatabaseContext())
|
|
return dbContext.Users.Where(u => u.Id == this.UserId).FirstOrDefault()?.Client;
|
|
}
|
|
}
|
|
}
|
|
}
|