Created API Controllers (#1)
Removed strongly typed inventory objects Added EAV inventory types Added EAV object handling philosophy Added controllers Added EF Core migration integration Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
namespace WyvernInventory.Core.Interfaces.Repos;
|
||||
|
||||
public interface IDbObjectRepo<T>
|
||||
public interface IDbObjectRepo<T, TDto>
|
||||
{
|
||||
public Task<List<T>> GetAsync(Predicate<T>? filter = null);
|
||||
public Task<List<TDto>> GetAsync(List<T>? filterList = null);
|
||||
public Task<(int created, int updated)> UpsertAsync(List<T> items);
|
||||
public Task DeleteAsync(List<T> items);
|
||||
public Task<int> DeleteAsync(List<T> items);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using WyvernInventory.Core.Models;
|
||||
|
||||
namespace WyvernInventory.Core.Interfaces.Repos;
|
||||
|
||||
public interface IInventoryItemRepo
|
||||
{
|
||||
public Task<List<InventoryItemDto>> GetAsync(List<InventoryItemRequest>? filterList = null);
|
||||
public Task<(int created, int updated)> UpsertAsync(List<InventoryItemRequest> items);
|
||||
public Task<int> DeleteAsync(List<InventoryItemRequest> items);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace WyvernInventory.Core.Interfaces.Services;
|
||||
|
||||
public interface IDataObjectService<T>
|
||||
public interface IDataObjectService<T, TDto>
|
||||
{
|
||||
public Task<List<T>> GetAsync(Predicate<T>? filter = null);
|
||||
public Task<List<TDto>> GetAsync(List<T>? filter = null);
|
||||
public Task<(int created, int updated)> UpsertAsync(List<T> items);
|
||||
public Task DeleteAsync(List<T> items);
|
||||
public Task<int> DeleteAsync(List<T> items);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using WyvernInventory.Core.Models;
|
||||
|
||||
namespace WyvernInventory.Core.Interfaces.Services;
|
||||
|
||||
public interface IInventoryItemService
|
||||
{
|
||||
public Task<List<InventoryItemDto>> GetAsync(List<InventoryItemRequest>? filter = null);
|
||||
public Task<(int created, int updated)> UpsertAsync(List<InventoryItemRequest> items);
|
||||
public Task<int> DeleteAsync(List<InventoryItemRequest> items);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record Computer() : GenericInventoryItem
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record Cpu() : GenericInventoryItem
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public class Enums
|
||||
{
|
||||
public enum DataType
|
||||
{
|
||||
String,
|
||||
Int,
|
||||
Decimal,
|
||||
Bool,
|
||||
DateTime
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record Gpu() : GenericInventoryItem
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record InventoryAttributeDefinition
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? TypeId { get; set; }
|
||||
public InventoryType? Type { get; set; } = null!;
|
||||
public string? Name { get; set; } = "";
|
||||
public Enums.DataType? DataType { get; set; }
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record GenericInventoryItem()
|
||||
public record InventoryAttributeDefinitionDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public Enums.DataType? DataType { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record InventoryAttributeValue
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ItemId { get; set; }
|
||||
public InventoryItem? Item { get; set; } = null!;
|
||||
public int? AttributeDefinitionId { get; set; }
|
||||
public InventoryAttributeDefinition? AttributeDefinition { get; set; } = null!;
|
||||
|
||||
public string? StringValue { get; set; }
|
||||
public int? IntValue { get; set; }
|
||||
public decimal? DecimalValue { get; set; }
|
||||
public bool? BoolValue { get; set; }
|
||||
public DateTime? DateTimeValue { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record InventoryAttributeValueDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ItemId { get; set; }
|
||||
public InventoryItemDto? Item { get; set; } = null!;
|
||||
public int? AttributeDefinitionId { get; set; }
|
||||
public InventoryAttributeDefinitionDto? AttributeDefinition { get; set; } = null!;
|
||||
|
||||
public string? StringValue { get; set; }
|
||||
public int? IntValue { get; set; }
|
||||
public decimal? DecimalValue { get; set; }
|
||||
public bool? BoolValue { get; set; }
|
||||
public DateTime? DateTimeValue { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record InventoryAttributeValueRequest
|
||||
{
|
||||
|
||||
public int? Id { get; set; }
|
||||
public int? ItemId { get; set; }
|
||||
public int? AttributeDefinitionId { get; set; }
|
||||
|
||||
public string? StringValue { get; set; }
|
||||
public int? IntValue { get; set; }
|
||||
public decimal? DecimalValue { get; set; }
|
||||
public bool? BoolValue { get; set; }
|
||||
public DateTime? DateTimeValue { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record InventoryItem
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; } = "";
|
||||
public int? TypeId { get; set; }
|
||||
public InventoryType? Type { get; set; } = null!;
|
||||
public List<InventoryAttributeValue>? AttributeValues { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record InventoryItemDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = "";
|
||||
public InventoryTypeDto Type { get; set; }
|
||||
public List<InventoryAttributeValueDto> AttributeValues { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record InventoryItemRequest
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; } = "";
|
||||
public int? TypeId { get; set; }
|
||||
public List<InventoryAttributeValueRequest>? AttributeValues { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record InventoryType
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; } = "";
|
||||
public List<InventoryAttributeDefinition> AttributeDefinitions { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record InventoryTypeDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public List<InventoryAttributeDefinitionDto>? AttributeDefinitions { get; set; }
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record Router() : GenericInventoryItem
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record StorageDrive() : GenericInventoryItem
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace WyvernInventory.Core.Models;
|
||||
|
||||
public record Switch() : GenericInventoryItem
|
||||
{
|
||||
|
||||
}
|
||||
@@ -8,4 +8,17 @@
|
||||
<RootNamespace>WyvernInventory.Core</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.7" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.7">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.7" />
|
||||
<PackageReference Include="Serilog" Version="4.3.1" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="10.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user