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