Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Definitions/DTO/Comparers/DtoObjectMissingEntryComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Diagnostics.CodeAnalysis;

namespace Definitions.DTO.Comparers;

public class DtoObjectMissingEntryComparer : IEqualityComparer<DtoObjectMissingEntry>
{
public bool Equals(DtoObjectMissingEntry? x, DtoObjectMissingEntry? y)
{
if (x is null || y is null)
{
return false;
}

return
x.Id == y.Id
&& x.DatName == y.DatName
&& x.DatChecksum == y.DatChecksum
&& x.ObjectType == y.ObjectType;
}

public int GetHashCode([DisallowNull] DtoObjectMissingEntry obj)
=> HashCode.Combine(obj.Id, obj.DatName, obj.DatChecksum, obj.ObjectType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

namespace Definitions.DTO.Comparers;

public class DtoMissingObjectEntryComparer : IEqualityComparer<DtoMissingObjectEntry>
public class DtoObjectMissingUploadComparer : IEqualityComparer<DtoObjectMissingUpload>
{
public bool Equals(DtoMissingObjectEntry? x, DtoMissingObjectEntry? y)
public bool Equals(DtoObjectMissingUpload? x, DtoObjectMissingUpload? y)
{
if (x is null || y is null)
{
return false;
}

return x.DatName == y.DatName
return
x.DatName == y.DatName
&& x.DatChecksum == y.DatChecksum
&& x.ObjectType == y.ObjectType;
}

public int GetHashCode([DisallowNull] DtoMissingObjectEntry obj)
public int GetHashCode([DisallowNull] DtoObjectMissingUpload obj)
=> HashCode.Combine(obj.DatName, obj.DatChecksum, obj.ObjectType);
}
1 change: 0 additions & 1 deletion Definitions/DTO/DtoDatObjectEntry.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Definitions.DTO;


public record DtoDatObjectEntry(
UniqueObjectId Id,
string DatName,
Expand Down
9 changes: 9 additions & 0 deletions Definitions/DTO/DtoObjectMissingEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Definitions.ObjectModels.Types;

namespace Definitions.DTO;

public record DtoObjectMissingEntry(
UniqueObjectId Id,
string DatName,
uint32_t DatChecksum,
ObjectType ObjectType) : IHasId;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Definitions.DTO;

public record DtoMissingObjectEntry(
public record DtoObjectMissingUpload(
string DatName,
uint32_t DatChecksum,
ObjectType ObjectType);
6 changes: 6 additions & 0 deletions Definitions/DTO/Mappers/DtoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public static DtoObjectEntry ToDtoEntry(this TblObject table)
public static TblObject ToTable(this DtoObjectEntry dto)
=> new() { Id = dto.Id, Name = dto.InternalName, Description = dto.Description, ObjectSource = dto.ObjectSource, ObjectType = dto.ObjectType, VehicleType = dto.VehicleType, CreatedDate = dto.CreatedDate, ModifiedDate = dto.ModifiedDate, UploadedDate = dto.UploadedDate };

public static DtoObjectMissingEntry ToDtoEntry(this TblObjectMissing table)
=> new(table.Id, table.DatName, table.DatChecksum, table.ObjectType);

public static TblObjectMissing ToTable(this DtoObjectMissingEntry dto)
=> new() { Id = dto.Id, DatName = dto.DatName, DatChecksum = dto.DatChecksum, ObjectType = dto.ObjectType };

public static DtoScenarioEntry ToDtoEntry(this TblSC5File table)
=> new(table.Id, table.Name);

Expand Down
14 changes: 14 additions & 0 deletions Definitions/Database/DataTables/TblObjectMissing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Definitions.ObjectModels.Types;
using Microsoft.EntityFrameworkCore;

namespace Definitions.Database;

[Index(nameof(DatName), nameof(DatChecksum), IsUnique = true)]
public class TblObjectMissing : DbIdObject
{
public required string DatName { get; set; }

public required uint DatChecksum { get; set; }

public required ObjectType ObjectType { get; set; }
}
1 change: 1 addition & 0 deletions Definitions/Database/LocoDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class LocoDbContext : IdentityDbContext<TblUser, TblUserRole, UniqueObjec
public DbSet<TblObject> Objects => Set<TblObject>();
public DbSet<TblStringTableRow> StringTable => Set<TblStringTableRow>();
public DbSet<TblDatObject> DatObjects => Set<TblDatObject>();
public DbSet<TblObjectMissing> ObjectsMissing => Set<TblObjectMissing>();

#region Objects

Expand Down
Loading