From ebf181c595ac094c042de828ff4df58be2aba116 Mon Sep 17 00:00:00 2001 From: CESARDELATORRE Date: Mon, 28 Nov 2016 17:34:21 -0800 Subject: [PATCH] Minor changes in Catalog API --- .../Catalog.API/Controllers/CatalogController.cs | 5 ----- .../Catalog.API/Infrastructure/CatalogContext.cs | 8 -------- .../Catalog.API/Infrastructure/CatalogContextSeed.cs | 12 ++++++++---- .../Catalog.API/Infrastructure/CatalogItem.cs | 6 +++--- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs index abb0733b3..64a7cd8eb 100644 --- a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs +++ b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs @@ -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 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 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 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 CatalogTypes() @@ -108,7 +104,6 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers } // GET api/v1/[controller]/CatalogBrands - [HttpGet] [Route("[action]")] public async Task CatalogBrands() diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs index 3ad04aed4..9655a9e1b 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs @@ -8,20 +8,14 @@ public CatalogContext(DbContextOptions options) : base(options) { } - public DbSet CatalogItems { get; set; } - public DbSet CatalogBrands { get; set; } - public DbSet CatalogTypes { get; set; } - protected override void OnModelCreating(ModelBuilder builder) { builder.Entity(ConfigureCatalogBrand); builder.Entity(ConfigureCatalogType); builder.Entity(ConfigureCatalogItem); - - } void ConfigureCatalogItem(EntityTypeBuilder builder) @@ -49,7 +43,6 @@ builder.HasOne(ci => ci.CatalogType) .WithMany() .HasForeignKey(ci => ci.CatalogTypeId); - } void ConfigureCatalogBrand(EntityTypeBuilder builder) @@ -69,7 +62,6 @@ void ConfigureCatalogType(EntityTypeBuilder builder) { - builder.ToTable("CatalogType"); builder.HasKey(ci => ci.Id); diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs index 105ef79cf..4d2b7f9fb 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs @@ -47,8 +47,10 @@ { return new List() { - 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() { - 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" } }; } diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogItem.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogItem.cs index 0c01486e1..65aafa457 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogItem.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogItem.cs @@ -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; }