mirror-ac/server/Database/Entity/HardwareConfiguration.cs
2023-09-10 21:12:38 +10:00

44 lines
1.4 KiB
C#

using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using server.Database.Model;
using System.Reflection.Metadata.Ecma335;
using Microsoft.EntityFrameworkCore;
namespace server.Database.Entity
{
public class HardwareConfigurationEntity : HardwareConfiguration
{
private readonly ModelContext _modelContext;
public UserEntity UserEntity { get; set; }
public HardwareConfigurationEntity(ModelContext modelContext)
{
UserEntity = new UserEntity(modelContext);
_modelContext = modelContext;
}
public bool CheckIfHardwareIsBanned()
{
return _modelContext.HardwareConfiguration.Any(
h => h.MotherboardSerial == MotherboardSerial &&
h.DeviceDrive0Serial == DeviceDrive0Serial &&
h.IsBanned);
}
public bool CheckIfHardwareExists()
{
return _modelContext.HardwareConfiguration.Any(
h => h.MotherboardSerial == MotherboardSerial &&
h.DeviceDrive0Serial == DeviceDrive0Serial);
}
public void InsertHardwareConfiguration()
{
_modelContext.HardwareConfiguration.Add(this);
}
}
}