using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using ReallifeGamemode.Database.Models;

namespace ReallifeGamemode.Database.Entities
{
  public partial class VehicleItem
  {
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }

    public int ItemId { get; set; }

    [ForeignKey("ServerVehicle")]
    public int VehicleId { get; set; }
    public ServerVehicle Vehicle { get; set; }

    public int Amount { get; set; }
    public int Slot { get; set; }

    public ServerVehicle GetVehicle()
    {
      using (var dbContext = new DatabaseContext())
      {
        return dbContext.ServerVehicles.FirstOrDefault(v => v.Id == VehicleId);
      }
    }
  }
}
