mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Full code refactor and clean-up.
This commit is contained in:
@@ -25,13 +25,12 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace RomRepoMgr.Database.Models
|
||||
{
|
||||
public abstract class BaseModel<TKey>
|
||||
{
|
||||
public TKey Id { get; set; }
|
||||
namespace RomRepoMgr.Database.Models;
|
||||
|
||||
public DateTime CreatedOn { get; set; }
|
||||
public DateTime UpdatedOn { get; set; }
|
||||
}
|
||||
public abstract class BaseModel<TKey>
|
||||
{
|
||||
public TKey Id { get; set; }
|
||||
|
||||
public DateTime CreatedOn { get; set; }
|
||||
public DateTime UpdatedOn { get; set; }
|
||||
}
|
||||
@@ -27,18 +27,17 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RomRepoMgr.Database.Models
|
||||
namespace RomRepoMgr.Database.Models;
|
||||
|
||||
public class DbDisk : BaseModel<ulong>
|
||||
{
|
||||
public class DbDisk : BaseModel<ulong>
|
||||
{
|
||||
public ulong? Size { get; set; }
|
||||
[StringLength(32, MinimumLength = 32)]
|
||||
public string Md5 { get; set; }
|
||||
[StringLength(40, MinimumLength = 40)]
|
||||
public string Sha1 { get; set; }
|
||||
[DefaultValue(false)]
|
||||
public bool IsInRepo { get; set; }
|
||||
public string OriginalFileName { get; set; }
|
||||
public virtual ICollection<DiskByMachine> Machines { get; set; }
|
||||
}
|
||||
public ulong? Size { get; set; }
|
||||
[StringLength(32, MinimumLength = 32)]
|
||||
public string Md5 { get; set; }
|
||||
[StringLength(40, MinimumLength = 40)]
|
||||
public string Sha1 { get; set; }
|
||||
[DefaultValue(false)]
|
||||
public bool IsInRepo { get; set; }
|
||||
public string OriginalFileName { get; set; }
|
||||
public virtual ICollection<DiskByMachine> Machines { get; set; }
|
||||
}
|
||||
@@ -27,27 +27,26 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RomRepoMgr.Database.Models
|
||||
namespace RomRepoMgr.Database.Models;
|
||||
|
||||
public class DbFile : BaseModel<ulong>
|
||||
{
|
||||
public class DbFile : BaseModel<ulong>
|
||||
{
|
||||
[Required]
|
||||
public ulong Size { get; set; }
|
||||
[StringLength(8, MinimumLength = 8)]
|
||||
public string Crc32 { get; set; }
|
||||
[StringLength(32, MinimumLength = 32)]
|
||||
public string Md5 { get; set; }
|
||||
[StringLength(40, MinimumLength = 40)]
|
||||
public string Sha1 { get; set; }
|
||||
[StringLength(64, MinimumLength = 64)]
|
||||
public string Sha256 { get; set; }
|
||||
[StringLength(96, MinimumLength = 96)]
|
||||
public string Sha384 { get; set; }
|
||||
[StringLength(128, MinimumLength = 128)]
|
||||
public string Sha512 { get; set; }
|
||||
[DefaultValue(false)]
|
||||
public bool IsInRepo { get; set; }
|
||||
public string OriginalFileName { get; set; }
|
||||
public virtual ICollection<FileByMachine> Machines { get; set; }
|
||||
}
|
||||
[Required]
|
||||
public ulong Size { get; set; }
|
||||
[StringLength(8, MinimumLength = 8)]
|
||||
public string Crc32 { get; set; }
|
||||
[StringLength(32, MinimumLength = 32)]
|
||||
public string Md5 { get; set; }
|
||||
[StringLength(40, MinimumLength = 40)]
|
||||
public string Sha1 { get; set; }
|
||||
[StringLength(64, MinimumLength = 64)]
|
||||
public string Sha256 { get; set; }
|
||||
[StringLength(96, MinimumLength = 96)]
|
||||
public string Sha384 { get; set; }
|
||||
[StringLength(128, MinimumLength = 128)]
|
||||
public string Sha512 { get; set; }
|
||||
[DefaultValue(false)]
|
||||
public bool IsInRepo { get; set; }
|
||||
public string OriginalFileName { get; set; }
|
||||
public virtual ICollection<FileByMachine> Machines { get; set; }
|
||||
}
|
||||
@@ -27,21 +27,20 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RomRepoMgr.Database.Models
|
||||
namespace RomRepoMgr.Database.Models;
|
||||
|
||||
public class DbMedia : BaseModel<ulong>
|
||||
{
|
||||
public class DbMedia : BaseModel<ulong>
|
||||
{
|
||||
public ulong? Size { get; set; }
|
||||
[StringLength(32, MinimumLength = 32)]
|
||||
public string Md5 { get; set; }
|
||||
[StringLength(40, MinimumLength = 40)]
|
||||
public string Sha1 { get; set; }
|
||||
[StringLength(64, MinimumLength = 64)]
|
||||
public string Sha256 { get; set; }
|
||||
public string SpamSum { get; set; }
|
||||
[DefaultValue(false)]
|
||||
public bool IsInRepo { get; set; }
|
||||
public string OriginalFileName { get; set; }
|
||||
public virtual IEnumerable<MediaByMachine> Machines { get; set; }
|
||||
}
|
||||
public ulong? Size { get; set; }
|
||||
[StringLength(32, MinimumLength = 32)]
|
||||
public string Md5 { get; set; }
|
||||
[StringLength(40, MinimumLength = 40)]
|
||||
public string Sha1 { get; set; }
|
||||
[StringLength(64, MinimumLength = 64)]
|
||||
public string Sha256 { get; set; }
|
||||
public string SpamSum { get; set; }
|
||||
[DefaultValue(false)]
|
||||
public bool IsInRepo { get; set; }
|
||||
public string OriginalFileName { get; set; }
|
||||
public virtual IEnumerable<MediaByMachine> Machines { get; set; }
|
||||
}
|
||||
@@ -25,19 +25,18 @@
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RomRepoMgr.Database.Models
|
||||
namespace RomRepoMgr.Database.Models;
|
||||
|
||||
public class DiskByMachine
|
||||
{
|
||||
public class DiskByMachine
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
[Required]
|
||||
public virtual DbDisk Disk { get; set; }
|
||||
[Required]
|
||||
public virtual Machine Machine { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public ulong DiskId { get; set; }
|
||||
public ulong MachineId { get; set; }
|
||||
}
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
[Required]
|
||||
public virtual DbDisk Disk { get; set; }
|
||||
[Required]
|
||||
public virtual Machine Machine { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public ulong DiskId { get; set; }
|
||||
public ulong MachineId { get; set; }
|
||||
}
|
||||
@@ -26,22 +26,21 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RomRepoMgr.Database.Models
|
||||
namespace RomRepoMgr.Database.Models;
|
||||
|
||||
public class FileByMachine
|
||||
{
|
||||
public class FileByMachine
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
[Required]
|
||||
public virtual DbFile File { get; set; }
|
||||
[Required]
|
||||
public virtual Machine Machine { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public ulong FileId { get; set; }
|
||||
public ulong MachineId { get; set; }
|
||||
public DateTime? FileLastModification { get; set; }
|
||||
[StringLength(4096)]
|
||||
public string Path { get; set; }
|
||||
}
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
[Required]
|
||||
public virtual DbFile File { get; set; }
|
||||
[Required]
|
||||
public virtual Machine Machine { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public ulong FileId { get; set; }
|
||||
public ulong MachineId { get; set; }
|
||||
public DateTime? FileLastModification { get; set; }
|
||||
[StringLength(4096)]
|
||||
public string Path { get; set; }
|
||||
}
|
||||
@@ -26,17 +26,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RomRepoMgr.Database.Models
|
||||
namespace RomRepoMgr.Database.Models;
|
||||
|
||||
public class Machine : BaseModel<ulong>
|
||||
{
|
||||
public class Machine : BaseModel<ulong>
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public virtual RomSet RomSet { get; set; }
|
||||
public virtual ICollection<FileByMachine> Files { get; set; }
|
||||
public virtual ICollection<DiskByMachine> Disks { get; set; }
|
||||
public virtual ICollection<MediaByMachine> Medias { get; set; }
|
||||
public long RomSetId { get; set; }
|
||||
}
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public virtual RomSet RomSet { get; set; }
|
||||
public virtual ICollection<FileByMachine> Files { get; set; }
|
||||
public virtual ICollection<DiskByMachine> Disks { get; set; }
|
||||
public virtual ICollection<MediaByMachine> Medias { get; set; }
|
||||
public long RomSetId { get; set; }
|
||||
}
|
||||
@@ -25,19 +25,18 @@
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RomRepoMgr.Database.Models
|
||||
namespace RomRepoMgr.Database.Models;
|
||||
|
||||
public class MediaByMachine
|
||||
{
|
||||
public class MediaByMachine
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
[Required]
|
||||
public virtual DbMedia Media { get; set; }
|
||||
[Required]
|
||||
public virtual Machine Machine { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public ulong MediaId { get; set; }
|
||||
public ulong MachineId { get; set; }
|
||||
}
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
[Required]
|
||||
public virtual DbMedia Media { get; set; }
|
||||
[Required]
|
||||
public virtual Machine Machine { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public ulong MediaId { get; set; }
|
||||
public ulong MachineId { get; set; }
|
||||
}
|
||||
@@ -26,24 +26,24 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RomRepoMgr.Database.Models
|
||||
{
|
||||
public class RomSet : BaseModel<long>
|
||||
{
|
||||
public string Author { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Homepage { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Version { get; set; }
|
||||
[Required]
|
||||
public string Filename { get; set; }
|
||||
[Required, StringLength(96, MinimumLength = 96)]
|
||||
public string Sha384 { get; set; }
|
||||
public string Category { get; set; }
|
||||
public virtual RomSetStat Statistics { get; set; }
|
||||
namespace RomRepoMgr.Database.Models;
|
||||
|
||||
public virtual ICollection<Machine> Machines { get; set; }
|
||||
}
|
||||
public class RomSet : BaseModel<long>
|
||||
{
|
||||
public string Author { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Homepage { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Version { get; set; }
|
||||
[Required]
|
||||
public string Filename { get; set; }
|
||||
[Required]
|
||||
[StringLength(96, MinimumLength = 96)]
|
||||
public string Sha384 { get; set; }
|
||||
public string Category { get; set; }
|
||||
public virtual RomSetStat Statistics { get; set; }
|
||||
|
||||
public virtual ICollection<Machine> Machines { get; set; }
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RomRepoMgr.Database.Models
|
||||
namespace RomRepoMgr.Database.Models;
|
||||
|
||||
public class RomSetStat
|
||||
{
|
||||
public class RomSetStat
|
||||
{
|
||||
public long TotalMachines { get; set; }
|
||||
public long CompleteMachines { get; set; }
|
||||
public long IncompleteMachines { get; set; }
|
||||
public long TotalRoms { get; set; }
|
||||
public long HaveRoms { get; set; }
|
||||
public long MissRoms { get; set; }
|
||||
public virtual RomSet RomSet { get; set; }
|
||||
[Key]
|
||||
public long RomSetId { get; set; }
|
||||
}
|
||||
public long TotalMachines { get; set; }
|
||||
public long CompleteMachines { get; set; }
|
||||
public long IncompleteMachines { get; set; }
|
||||
public long TotalRoms { get; set; }
|
||||
public long HaveRoms { get; set; }
|
||||
public long MissRoms { get; set; }
|
||||
public virtual RomSet RomSet { get; set; }
|
||||
[Key]
|
||||
public long RomSetId { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user