make : // TODO: Make a generic service for any LookupData type (#594)
* make : // TODO: Make a generic service for any LookupData type => CatalogLookupDataService * Update src/BlazorAdmin/Services/CachedCatalogTypeServiceDecorator.cs Co-authored-by: Steve Smith <steve@kentsmiths.com>
This commit is contained in:
9
src/BlazorShared/Attributes/EndpointAttribute.cs
Normal file
9
src/BlazorShared/Attributes/EndpointAttribute.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace BlazorShared.Attributes
|
||||
{
|
||||
public class EndpointAttribute : Attribute
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorShared.Models;
|
||||
|
||||
namespace BlazorShared.Interfaces
|
||||
{
|
||||
public interface ICatalogBrandService
|
||||
{
|
||||
Task<List<CatalogBrand>> List();
|
||||
Task<CatalogBrand> GetById(int id);
|
||||
}
|
||||
}
|
||||
12
src/BlazorShared/Interfaces/ICatalogLookupDataService.cs
Normal file
12
src/BlazorShared/Interfaces/ICatalogLookupDataService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using BlazorShared.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorShared.Interfaces
|
||||
{
|
||||
public interface ICatalogLookupDataService<TLookupData> where TLookupData : LookupData
|
||||
{
|
||||
Task<List<TLookupData>> List();
|
||||
Task<TLookupData> GetById(int id);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using BlazorShared.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorShared.Interfaces
|
||||
{
|
||||
public interface ICatalogTypeService
|
||||
{
|
||||
Task<List<CatalogType>> List();
|
||||
Task<CatalogType> GetById(int id);
|
||||
}
|
||||
}
|
||||
10
src/BlazorShared/Interfaces/ILookupDataResponse.cs
Normal file
10
src/BlazorShared/Interfaces/ILookupDataResponse.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using BlazorShared.Models;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BlazorShared.Interfaces
|
||||
{
|
||||
public interface ILookupDataResponse<TLookupData> where TLookupData : LookupData
|
||||
{
|
||||
List<TLookupData> List { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace BlazorShared.Models
|
||||
using BlazorShared.Attributes;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
{
|
||||
[Endpoint(Name = "catalog-brands")]
|
||||
public class CatalogBrand : LookupData
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using BlazorShared.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
{
|
||||
public class CatalogBrandResponse
|
||||
public class CatalogBrandResponse : ILookupDataResponse<CatalogBrand>
|
||||
{
|
||||
public List<CatalogBrand> CatalogBrands { get; set; } = new List<CatalogBrand>();
|
||||
[JsonPropertyName("CatalogBrands")]
|
||||
public List<CatalogBrand> List { get; set; } = new List<CatalogBrand>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace BlazorShared.Models
|
||||
using BlazorShared.Attributes;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
{
|
||||
[Endpoint(Name = "catalog-types")]
|
||||
public class CatalogType : LookupData
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using BlazorShared.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
{
|
||||
public class CatalogTypeResponse
|
||||
public class CatalogTypeResponse : ILookupDataResponse<CatalogType>
|
||||
{
|
||||
public List<CatalogType> CatalogTypes { get; set; } = new List<CatalogType>();
|
||||
|
||||
[JsonPropertyName("CatalogTypes")]
|
||||
public List<CatalogType> List { get; set; } = new List<CatalogType>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace BlazorShared.Models
|
||||
{
|
||||
public abstract class LookupData
|
||||
{
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user