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:
Cédric Michel
2021-10-26 16:59:50 +02:00
committed by GitHub
parent 8f55b1b56a
commit f6a975acbe
18 changed files with 122 additions and 140 deletions

View File

@@ -0,0 +1,9 @@
using System;
namespace BlazorShared.Attributes
{
public class EndpointAttribute : Attribute
{
public string Name { get; set; }
}
}

View File

@@ -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);
}
}

View 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);
}
}

View File

@@ -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);
}
}

View 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; }
}
}

View File

@@ -1,5 +1,8 @@
namespace BlazorShared.Models
using BlazorShared.Attributes;
namespace BlazorShared.Models
{
[Endpoint(Name = "catalog-brands")]
public class CatalogBrand : LookupData
{
}

View File

@@ -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>();
}
}

View File

@@ -1,5 +1,8 @@
namespace BlazorShared.Models
using BlazorShared.Attributes;
namespace BlazorShared.Models
{
[Endpoint(Name = "catalog-types")]
public class CatalogType : LookupData
{
}

View File

@@ -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>();
}
}

View File

@@ -1,7 +1,7 @@
namespace BlazorShared.Models
{
public abstract class LookupData
{
{
public int Id { get; set; }
public string Name { get; set; }
}