Minor changes in Catalog API
This commit is contained in:
parent
e3f7c083fc
commit
ebf181c595
@ -20,7 +20,6 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
||||
}
|
||||
|
||||
// GET api/v1/[controller]/items/[?pageSize=3&pageIndex=10]
|
||||
|
||||
[HttpGet]
|
||||
[Route("[action]")]
|
||||
public async Task<IActionResult> Items(int pageSize = 10, int pageIndex = 0)
|
||||
@ -41,7 +40,6 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
||||
}
|
||||
|
||||
// GET api/v1/[controller]/items/withname/samplename
|
||||
|
||||
[HttpGet]
|
||||
[Route("[action]/withname/{name:minlength(1)}")]
|
||||
public async Task<IActionResult> Items(string name, int pageSize = 10, int pageIndex = 0)
|
||||
@ -64,7 +62,6 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
||||
}
|
||||
|
||||
// GET api/v1/[controller]/items/type/1/brand/null
|
||||
|
||||
[HttpGet]
|
||||
[Route("[action]/type/{catalogTypeId}/brand/{catalogBrandId}")]
|
||||
public async Task<IActionResult> Items(int? catalogTypeId, int? catalogBrandId, int pageSize = 10, int pageIndex = 0)
|
||||
@ -96,7 +93,6 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
||||
}
|
||||
|
||||
// GET api/v1/[controller]/CatalogTypes
|
||||
|
||||
[HttpGet]
|
||||
[Route("[action]")]
|
||||
public async Task<IActionResult> CatalogTypes()
|
||||
@ -108,7 +104,6 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
||||
}
|
||||
|
||||
// GET api/v1/[controller]/CatalogBrands
|
||||
|
||||
[HttpGet]
|
||||
[Route("[action]")]
|
||||
public async Task<IActionResult> CatalogBrands()
|
||||
|
@ -8,20 +8,14 @@
|
||||
public CatalogContext(DbContextOptions options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<CatalogItem> CatalogItems { get; set; }
|
||||
|
||||
public DbSet<CatalogBrand> CatalogBrands { get; set; }
|
||||
|
||||
public DbSet<CatalogType> CatalogTypes { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
builder.Entity<CatalogBrand>(ConfigureCatalogBrand);
|
||||
builder.Entity<CatalogType>(ConfigureCatalogType);
|
||||
builder.Entity<CatalogItem>(ConfigureCatalogItem);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ConfigureCatalogItem(EntityTypeBuilder<CatalogItem> builder)
|
||||
@ -49,7 +43,6 @@
|
||||
builder.HasOne(ci => ci.CatalogType)
|
||||
.WithMany()
|
||||
.HasForeignKey(ci => ci.CatalogTypeId);
|
||||
|
||||
}
|
||||
|
||||
void ConfigureCatalogBrand(EntityTypeBuilder<CatalogBrand> builder)
|
||||
@ -69,7 +62,6 @@
|
||||
|
||||
void ConfigureCatalogType(EntityTypeBuilder<CatalogType> builder)
|
||||
{
|
||||
|
||||
builder.ToTable("CatalogType");
|
||||
|
||||
builder.HasKey(ci => ci.Id);
|
||||
|
@ -47,8 +47,10 @@
|
||||
{
|
||||
return new List<CatalogBrand>()
|
||||
{
|
||||
new CatalogBrand() { Brand="Azure"},
|
||||
new CatalogBrand() { Brand = "Visual Studio" }
|
||||
new CatalogBrand() { Brand = "Azure"},
|
||||
new CatalogBrand() { Brand = ".NET" },
|
||||
new CatalogBrand() { Brand = "Visual Studio" },
|
||||
new CatalogBrand() { Brand = "SQL Server" }
|
||||
};
|
||||
}
|
||||
|
||||
@ -56,8 +58,10 @@
|
||||
{
|
||||
return new List<CatalogType>()
|
||||
{
|
||||
new CatalogType() { Type="Mug"},
|
||||
new CatalogType() { Type = "T-Shirt" }
|
||||
new CatalogType() { Type = "Mug"},
|
||||
new CatalogType() { Type = "T-Shirt" },
|
||||
new CatalogType() { Type = "Backpack" },
|
||||
new CatalogType() { Type = "USB Memory Stick" }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
|
||||
{
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
|
||||
{
|
||||
public class CatalogItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user