Javier Suárez Ruiz 8 years ago
parent
commit
9201160fe1
13 changed files with 649 additions and 71 deletions
  1. +8
    -3
      docker-compose.yml
  2. +1
    -0
      src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs
  3. +15
    -24
      src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs
  4. +2
    -2
      src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs
  5. +99
    -0
      src/Services/Catalog/Catalog.API/Infrastructure/Migrations/20161103152832_Initial.Designer.cs
  6. +108
    -0
      src/Services/Catalog/Catalog.API/Infrastructure/Migrations/20161103152832_Initial.cs
  7. +99
    -0
      src/Services/Catalog/Catalog.API/Infrastructure/Migrations/20161103153420_UpdateTableNames.Designer.cs
  8. +161
    -0
      src/Services/Catalog/Catalog.API/Infrastructure/Migrations/20161103153420_UpdateTableNames.cs
  9. +98
    -0
      src/Services/Catalog/Catalog.API/Infrastructure/Migrations/CatalogContextModelSnapshot.cs
  10. +38
    -31
      src/Services/Catalog/Catalog.API/Startup.cs
  11. +8
    -4
      src/Services/Catalog/Catalog.API/project.json
  12. +1
    -1
      src/Services/Catalog/Catalog.API/settings.json
  13. +11
    -6
      src/Web/WebMVC/docker-compose.yml

+ 8
- 3
docker-compose.yml View File

@ -15,14 +15,19 @@ services:
catalog.api:
image: eshop/catalog.api:latest
environment:
- ConnectionString=Server=catalogdata;Port=5432;Database=postgres;username=postgres
- ConnectionString=Server=catalogdata;Initial Catalog=CatalogDB;User Id=sa;Password=Pass@word
expose:
- "80"
depends_on:
- catalogdata
catalogdata:
image: glennc/eshopdata
image: eshop/mssql-server-private-preview
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=Pass@word
ports:
- "1455:1433"
ordering.api:
image: eshop/ordering.api:latest
@ -43,7 +48,7 @@ services:
image: eshop/ordering.data.sqlserver.linux
ports:
- "1433:1433"
basket.api:
image: eshop/basket.api:latest
environment:


+ 1
- 0
src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs View File

@ -29,6 +29,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
.LongCountAsync();
var itemsOnPage = await _context.CatalogItems
.OrderBy(c=>c.Name)
.Skip(pageSize * pageIndex)
.Take(pageSize)
.ToListAsync();


+ 15
- 24
src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs View File

@ -2,7 +2,6 @@
{
using EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Npgsql.EntityFrameworkCore.PostgreSQL;
public class CatalogContext : DbContext
{
@ -18,32 +17,19 @@
protected override void OnModelCreating(ModelBuilder builder)
{
builder.HasSequence("idseqcatalog")
.StartsAt(1)
.IncrementsBy(1);
builder.HasSequence("idseqcatalogbrand")
.StartsAt(1)
.IncrementsBy(1);
builder.HasSequence("idseqcatalogtype")
.StartsAt(1)
.IncrementsBy(1);
builder.Entity<CatalogBrand>(ConfigureCatalogBrand);
builder.Entity<CatalogType>(ConfigureCatalogType);
builder.Entity<CatalogItem>(ConfigureCatalogItem);
builder.HasPostgresExtension("uuid-ossp");
}
void ConfigureCatalogItem(EntityTypeBuilder<CatalogItem> builder)
{
builder.ForNpgsqlToTable("catalog");
builder.ToTable("Catalog");
builder.Property(ci => ci.Id)
.HasDefaultValueSql("nextval('idseqcatalog')")
.ForSqlServerUseSequenceHiLo("catalog_hilo")
.IsRequired();
builder.Property(ci => ci.Name)
@ -68,11 +54,13 @@
void ConfigureCatalogBrand(EntityTypeBuilder<CatalogBrand> builder)
{
builder.ForNpgsqlToTable("catalogbrand");
builder.ToTable("CatalogBrand");
builder.Property(cb => cb.Id)
.HasDefaultValueSql("nextval('idseqcatalogbrand')")
.IsRequired();
builder.HasKey(ci => ci.Id);
builder.Property(ci => ci.Id)
.ForSqlServerUseSequenceHiLo("catalog_brand_hilo")
.IsRequired();
builder.Property(cb => cb.Brand)
.IsRequired()
@ -81,11 +69,14 @@
void ConfigureCatalogType(EntityTypeBuilder<CatalogType> builder)
{
builder.ForNpgsqlToTable("catalogtype");
builder.Property(cb => cb.Id)
.HasDefaultValueSql("nextval('idseqcatalogtype')")
.IsRequired();
builder.ToTable("CatalogType");
builder.HasKey(ci => ci.Id);
builder.Property(ci => ci.Id)
.ForSqlServerUseSequenceHiLo("catalog_type_hilo")
.IsRequired();
builder.Property(cb => cb.Type)
.IsRequired()


+ 2
- 2
src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs View File

@ -1,7 +1,7 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
{
using EntityFrameworkCore;
using Microsoft.AspNetCore.Builder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -15,7 +15,7 @@
using (context)
{
context.Database.EnsureCreated();
context.Database.Migrate();
if (!context.CatalogBrands.Any())
{


+ 99
- 0
src/Services/Catalog/Catalog.API/Infrastructure/Migrations/20161103152832_Initial.Designer.cs View File

@ -0,0 +1,99 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
namespace Catalog.API.Infrastructure.Migrations
{
[DbContext(typeof(CatalogContext))]
[Migration("20161103152832_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "1.0.1")
.HasAnnotation("SqlServer:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<string>("Brand")
.IsRequired()
.HasAnnotation("MaxLength", 100);
b.HasKey("Id");
b.ToTable("catalogbrand");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<int>("CatalogBrandId");
b.Property<int>("CatalogTypeId");
b.Property<string>("Description");
b.Property<string>("Name")
.IsRequired()
.HasAnnotation("MaxLength", 50);
b.Property<string>("PictureUri");
b.Property<decimal>("Price");
b.HasKey("Id");
b.HasIndex("CatalogBrandId");
b.HasIndex("CatalogTypeId");
b.ToTable("catalog");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<string>("Type")
.IsRequired()
.HasAnnotation("MaxLength", 100);
b.HasKey("Id");
b.ToTable("CatalogTypes");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b =>
{
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", "CatalogBrand")
.WithMany()
.HasForeignKey("CatalogBrandId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", "CatalogType")
.WithMany()
.HasForeignKey("CatalogTypeId")
.OnDelete(DeleteBehavior.Cascade);
});
}
}
}

+ 108
- 0
src/Services/Catalog/Catalog.API/Infrastructure/Migrations/20161103152832_Initial.cs View File

@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Catalog.API.Infrastructure.Migrations
{
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateSequence(
name: "catalog_brand_hilo",
incrementBy: 10);
migrationBuilder.CreateSequence(
name: "catalog_hilo",
incrementBy: 10);
migrationBuilder.CreateSequence(
name: "catalog_type_hilo",
incrementBy: 10);
migrationBuilder.CreateTable(
name: "catalogbrand",
columns: table => new
{
Id = table.Column<int>(nullable: false),
Brand = table.Column<string>(maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_catalogbrand", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CatalogTypes",
columns: table => new
{
Id = table.Column<int>(nullable: false),
Type = table.Column<string>(maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CatalogTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "catalog",
columns: table => new
{
Id = table.Column<int>(nullable: false),
CatalogBrandId = table.Column<int>(nullable: false),
CatalogTypeId = table.Column<int>(nullable: false),
Description = table.Column<string>(nullable: true),
Name = table.Column<string>(maxLength: 50, nullable: false),
PictureUri = table.Column<string>(nullable: true),
Price = table.Column<decimal>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_catalog", x => x.Id);
table.ForeignKey(
name: "FK_catalog_catalogbrand_CatalogBrandId",
column: x => x.CatalogBrandId,
principalTable: "catalogbrand",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_catalog_CatalogTypes_CatalogTypeId",
column: x => x.CatalogTypeId,
principalTable: "CatalogTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_catalog_CatalogBrandId",
table: "catalog",
column: "CatalogBrandId");
migrationBuilder.CreateIndex(
name: "IX_catalog_CatalogTypeId",
table: "catalog",
column: "CatalogTypeId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropSequence(
name: "catalog_brand_hilo");
migrationBuilder.DropSequence(
name: "catalog_hilo");
migrationBuilder.DropSequence(
name: "catalog_type_hilo");
migrationBuilder.DropTable(
name: "catalog");
migrationBuilder.DropTable(
name: "catalogbrand");
migrationBuilder.DropTable(
name: "CatalogTypes");
}
}
}

+ 99
- 0
src/Services/Catalog/Catalog.API/Infrastructure/Migrations/20161103153420_UpdateTableNames.Designer.cs View File

@ -0,0 +1,99 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
namespace Catalog.API.Infrastructure.Migrations
{
[DbContext(typeof(CatalogContext))]
[Migration("20161103153420_UpdateTableNames")]
partial class UpdateTableNames
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "1.0.1")
.HasAnnotation("SqlServer:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<string>("Brand")
.IsRequired()
.HasAnnotation("MaxLength", 100);
b.HasKey("Id");
b.ToTable("CatalogBrand");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<int>("CatalogBrandId");
b.Property<int>("CatalogTypeId");
b.Property<string>("Description");
b.Property<string>("Name")
.IsRequired()
.HasAnnotation("MaxLength", 50);
b.Property<string>("PictureUri");
b.Property<decimal>("Price");
b.HasKey("Id");
b.HasIndex("CatalogBrandId");
b.HasIndex("CatalogTypeId");
b.ToTable("Catalog");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<string>("Type")
.IsRequired()
.HasAnnotation("MaxLength", 100);
b.HasKey("Id");
b.ToTable("CatalogType");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b =>
{
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", "CatalogBrand")
.WithMany()
.HasForeignKey("CatalogBrandId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", "CatalogType")
.WithMany()
.HasForeignKey("CatalogTypeId")
.OnDelete(DeleteBehavior.Cascade);
});
}
}
}

+ 161
- 0
src/Services/Catalog/Catalog.API/Infrastructure/Migrations/20161103153420_UpdateTableNames.cs View File

@ -0,0 +1,161 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Catalog.API.Infrastructure.Migrations
{
public partial class UpdateTableNames : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_catalog_catalogbrand_CatalogBrandId",
table: "catalog");
migrationBuilder.DropForeignKey(
name: "FK_catalog_CatalogTypes_CatalogTypeId",
table: "catalog");
migrationBuilder.DropPrimaryKey(
name: "PK_CatalogTypes",
table: "CatalogTypes");
migrationBuilder.DropPrimaryKey(
name: "PK_catalog",
table: "catalog");
migrationBuilder.DropPrimaryKey(
name: "PK_catalogbrand",
table: "catalogbrand");
migrationBuilder.AddPrimaryKey(
name: "PK_CatalogType",
table: "CatalogTypes",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_Catalog",
table: "catalog",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_CatalogBrand",
table: "catalogbrand",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Catalog_CatalogBrand_CatalogBrandId",
table: "catalog",
column: "CatalogBrandId",
principalTable: "catalogbrand",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Catalog_CatalogType_CatalogTypeId",
table: "catalog",
column: "CatalogTypeId",
principalTable: "CatalogTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.RenameIndex(
name: "IX_catalog_CatalogTypeId",
table: "catalog",
newName: "IX_Catalog_CatalogTypeId");
migrationBuilder.RenameIndex(
name: "IX_catalog_CatalogBrandId",
table: "catalog",
newName: "IX_Catalog_CatalogBrandId");
migrationBuilder.RenameTable(
name: "CatalogTypes",
newName: "CatalogType");
migrationBuilder.RenameTable(
name: "catalog",
newName: "Catalog");
migrationBuilder.RenameTable(
name: "catalogbrand",
newName: "CatalogBrand");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Catalog_CatalogBrand_CatalogBrandId",
table: "Catalog");
migrationBuilder.DropForeignKey(
name: "FK_Catalog_CatalogType_CatalogTypeId",
table: "Catalog");
migrationBuilder.DropPrimaryKey(
name: "PK_CatalogType",
table: "CatalogType");
migrationBuilder.DropPrimaryKey(
name: "PK_Catalog",
table: "Catalog");
migrationBuilder.DropPrimaryKey(
name: "PK_CatalogBrand",
table: "CatalogBrand");
migrationBuilder.AddPrimaryKey(
name: "PK_CatalogTypes",
table: "CatalogType",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_catalog",
table: "Catalog",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_catalogbrand",
table: "CatalogBrand",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_catalog_catalogbrand_CatalogBrandId",
table: "Catalog",
column: "CatalogBrandId",
principalTable: "CatalogBrand",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_catalog_CatalogTypes_CatalogTypeId",
table: "Catalog",
column: "CatalogTypeId",
principalTable: "CatalogType",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.RenameIndex(
name: "IX_Catalog_CatalogTypeId",
table: "Catalog",
newName: "IX_catalog_CatalogTypeId");
migrationBuilder.RenameIndex(
name: "IX_Catalog_CatalogBrandId",
table: "Catalog",
newName: "IX_catalog_CatalogBrandId");
migrationBuilder.RenameTable(
name: "CatalogType",
newName: "CatalogTypes");
migrationBuilder.RenameTable(
name: "Catalog",
newName: "catalog");
migrationBuilder.RenameTable(
name: "CatalogBrand",
newName: "catalogbrand");
}
}
}

+ 98
- 0
src/Services/Catalog/Catalog.API/Infrastructure/Migrations/CatalogContextModelSnapshot.cs View File

@ -0,0 +1,98 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
namespace Catalog.API.Infrastructure.Migrations
{
[DbContext(typeof(CatalogContext))]
partial class CatalogContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "1.0.1")
.HasAnnotation("SqlServer:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<string>("Brand")
.IsRequired()
.HasAnnotation("MaxLength", 100);
b.HasKey("Id");
b.ToTable("CatalogBrand");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<int>("CatalogBrandId");
b.Property<int>("CatalogTypeId");
b.Property<string>("Description");
b.Property<string>("Name")
.IsRequired()
.HasAnnotation("MaxLength", 50);
b.Property<string>("PictureUri");
b.Property<decimal>("Price");
b.HasKey("Id");
b.HasIndex("CatalogBrandId");
b.HasIndex("CatalogTypeId");
b.ToTable("Catalog");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<string>("Type")
.IsRequired()
.HasAnnotation("MaxLength", 100);
b.HasKey("Id");
b.ToTable("CatalogType");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b =>
{
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", "CatalogBrand")
.WithMany()
.HasForeignKey("CatalogBrandId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", "CatalogType")
.WithMany()
.HasForeignKey("CatalogTypeId")
.OnDelete(DeleteBehavior.Cascade);
});
}
}
}

+ 38
- 31
src/Services/Catalog/Catalog.API/Startup.cs View File

@ -1,18 +1,14 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Serialization;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Catalog.API
namespace Microsoft.eShopOnContainers.Services.Catalog.API
{
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
public class Startup
{
public IConfigurationRoot Configuration { get; }
@ -21,47 +17,55 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile($"settings.json",optional:false)
.AddJsonFile($"settings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"settings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IConfiguration>(Configuration);
services.AddDbContext<CatalogContext>(c =>
services.AddDbContext<CatalogContext>(c =>
{
c.UseNpgsql(Configuration["ConnectionString"]);
c.UseSqlServer(Configuration["ConnectionString"]);
c.ConfigureWarnings(wb =>
{
wb.Throw(RelationalEventId.QueryClientEvaluationWarning);
//By default, in this application, we don't want to have client evaluations
wb.Log(RelationalEventId.QueryClientEvaluationWarning);
});
});
// Add framework services.
services.AddSwaggerGen();
services.ConfigureSwaggerGen(options =>
{
options.DescribeAllEnumsAsStrings();
options.SingleApiVersion(new Swashbuckle.Swagger.Model.Info()
{
Title = "Catalog HTTP API",
Version = "v1",
Description = "The Catalog Service HTTP API",
TermsOfService = "Terms Of Service"
});
});
services.AddCors();
services.AddMvcCore()
.AddJsonFormatters(settings=>
{
settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
});
services.AddMvc(mvcoptions =>
{
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//Configure logs
if(env.IsDevelopment())
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
@ -74,9 +78,12 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
.Wait();
// Use frameworks
app.UseCors(policyBuilder=>policyBuilder.AllowAnyOrigin());
app.UseCors(policyBuilder => policyBuilder.AllowAnyOrigin());
app.UseMvc();
app.UseSwagger()
.UseSwaggerUi();
}
}
}

+ 8
- 4
src/Services/Catalog/Catalog.API/project.json View File

@ -3,22 +3,26 @@
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
},
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.Abstractions": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.EntityFrameworkCore": "1.0.1",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.2"
"Microsoft.EntityFrameworkCore": "1.0.1",
"Microsoft.EntityFrameworkCore.Relational": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final",
"Swashbuckle": "6.0.0-beta902"
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {


+ 1
- 1
src/Services/Catalog/Catalog.API/settings.json View File

@ -1,5 +1,5 @@
{
"ConnectionString": "Server=127.0.0.1;Port=5432;Database=CatalogDB;username=postgres;password=postgres",
"ConnectionString": "Server=tcp:127.0.0.1,1455;Initial Catalog=CatalogDB;User Id=sa;Password=Pass@word",
"Logging": {
"IncludeScopes": false,
"LogLevel": {


+ 11
- 6
src/Web/WebMVC/docker-compose.yml View File

@ -10,7 +10,7 @@ services:
- CatalogUrl=http://catalog.api
- OrderingUrl=http://ordering.api
ports:
- "5000:80"
- "5100:80"
depends_on:
- catalog.api
- identity.data
@ -18,16 +18,21 @@ services:
catalog.api:
image: eshop/catalog.api
environment:
- ConnectionString=Server=catalogdata;Port=5432;Database=CatalogDB;username=postgres;password=postgres
- ConnectionString=Server=catalog.data;Initial Catalog=CatalogData;User Id=sa;Password=Pass@word
expose:
- "80"
ports:
- "5001:80"
- "5101:80"
depends_on:
- catalogdata
- catalog.data
catalogdata:
image: glennc/eshopdata
catalog.data:
image: eshop/mssql-server-private-preview
environment:
- SA_PASSWORD=Pass@word
- ACCEPT_EULA=Y
ports:
- "5434:1433"
ordering.api:
image: eshop/ordering.api


Loading…
Cancel
Save