mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Fix reformatting.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Data.Common;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
@@ -37,36 +38,32 @@ namespace DiscImageChef.Server.Models
|
||||
{
|
||||
public sealed class DicServerContext : DbContext
|
||||
{
|
||||
public DicServerContext()
|
||||
{
|
||||
}
|
||||
public DicServerContext() { }
|
||||
|
||||
public DicServerContext(DbContextOptions<DicServerContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
public DicServerContext(DbContextOptions<DicServerContext> options) : base(options) { }
|
||||
|
||||
public DbSet<Device> Devices { get; set; }
|
||||
public DbSet<UploadedReport> Reports { get; set; }
|
||||
public DbSet<Command> Commands { get; set; }
|
||||
public DbSet<DeviceStat> DeviceStats { get; set; }
|
||||
public DbSet<Filesystem> Filesystems { get; set; }
|
||||
public DbSet<Filter> Filters { get; set; }
|
||||
public DbSet<Media> Medias { get; set; }
|
||||
public DbSet<MediaFormat> MediaFormats { get; set; }
|
||||
public DbSet<OperatingSystem> OperatingSystems { get; set; }
|
||||
public DbSet<Partition> Partitions { get; set; }
|
||||
public DbSet<Version> Versions { get; set; }
|
||||
public DbSet<UsbVendor> UsbVendors { get; set; }
|
||||
public DbSet<UsbProduct> UsbProducts { get; set; }
|
||||
public DbSet<CompactDiscOffset> CdOffsets { get; set; }
|
||||
public DbSet<Device> Devices { get; set; }
|
||||
public DbSet<UploadedReport> Reports { get; set; }
|
||||
public DbSet<Command> Commands { get; set; }
|
||||
public DbSet<DeviceStat> DeviceStats { get; set; }
|
||||
public DbSet<Filesystem> Filesystems { get; set; }
|
||||
public DbSet<Filter> Filters { get; set; }
|
||||
public DbSet<Media> Medias { get; set; }
|
||||
public DbSet<MediaFormat> MediaFormats { get; set; }
|
||||
public DbSet<OperatingSystem> OperatingSystems { get; set; }
|
||||
public DbSet<Partition> Partitions { get; set; }
|
||||
public DbSet<Version> Versions { get; set; }
|
||||
public DbSet<UsbVendor> UsbVendors { get; set; }
|
||||
public DbSet<UsbProduct> UsbProducts { get; set; }
|
||||
public DbSet<CompactDiscOffset> CdOffsets { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured) return;
|
||||
if(optionsBuilder.IsConfigured)
|
||||
return;
|
||||
|
||||
|
||||
var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
|
||||
var configuration = builder.Build();
|
||||
IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
|
||||
IConfigurationRoot configuration = builder.Build();
|
||||
optionsBuilder.UseMySql(configuration.GetConnectionString("DefaultConnection"));
|
||||
}
|
||||
|
||||
@@ -86,16 +83,17 @@ namespace DiscImageChef.Server.Models
|
||||
|
||||
internal static bool TableExists(string tableName)
|
||||
{
|
||||
using (var db = new DicServerContext())
|
||||
using(var db = new DicServerContext())
|
||||
{
|
||||
var connection = db.Database.GetDbConnection();
|
||||
DbConnection connection = db.Database.GetDbConnection();
|
||||
connection.Open();
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
DbCommand command = connection.CreateCommand();
|
||||
|
||||
command.CommandText =
|
||||
$"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=\"{tableName}\"";
|
||||
|
||||
var result = (long) command.ExecuteScalar();
|
||||
long result = (long)command.ExecuteScalar();
|
||||
|
||||
return result != 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user