using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using GTANetworkAPI;
using Newtonsoft.Json;
using ReallifeGamemode.Server.Core.API;

namespace ReallifeGamemode.Database.Entities
{
  public partial class Interior
  {
    [NotMapped]
    private Position _enterPosition;
    [NotMapped]
    private Position _exitPosition;

    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }
    public string Name { get; set; }

    [Column("EnterPosition")]
    public string EnterPositionStr
    {
      get
      {
        return JsonConvert.SerializeObject(this._enterPosition);
      }
      set
      {
        this._enterPosition = JsonConvert.DeserializeObject<Position>(value);
      }
    }

    [Column("ExitPosition")]
    public string ExitPositionStr
    {
      get
      {
        return JsonConvert.SerializeObject(this._exitPosition);
      }
      set
      {
        this._exitPosition = JsonConvert.DeserializeObject<Position>(value);
      }
    }

    [NotMapped]
    public Position EnterPosition
    {
      get
      {
        return this._enterPosition;
      }
      set
      {
        this._enterPosition = value;
      }
    }

    [NotMapped]
    public Position ExitPosition
    {
      get
      {
        return this._exitPosition;
      }
      set
      {
        this._exitPosition = value;
      }
    }
  }
}
