Browse Source

read catalog API from web config

Instead of hard coding.
pull/168/head
BillWagner 7 years ago
committed by Bill Wagner
parent
commit
787864af0b
2 changed files with 15 additions and 14 deletions
  1. +14
    -14
      src/Web/Catalog.WebForms/Catalog.WebForms/Services/CatalogService.cs
  2. +1
    -0
      src/Web/Catalog.WebForms/Catalog.WebForms/Web.config

+ 14
- 14
src/Web/Catalog.WebForms/Catalog.WebForms/Services/CatalogService.cs View File

@ -23,8 +23,8 @@ namespace eShopOnContainers.Core.Services.Catalog
{ {
try try
{ {
// TODO:
UriBuilder builder = new UriBuilder("http://catalog.api:5101");
var baseURl = System.Configuration.ConfigurationManager.AppSettings["CatalogURL"];
UriBuilder builder = new UriBuilder(baseURl);
builder.Path = string.Format("api/v1/catalog/items/type/{0}/brand/{1}", catalogTypeId, catalogBrandId); builder.Path = string.Format("api/v1/catalog/items/type/{0}/brand/{1}", catalogTypeId, catalogBrandId);
@ -48,8 +48,8 @@ namespace eShopOnContainers.Core.Services.Catalog
{ {
try try
{ {
// TODO:
UriBuilder builder = new UriBuilder("http://catalog.api:5101");
var baseURl = System.Configuration.ConfigurationManager.AppSettings["CatalogURL"];
UriBuilder builder = new UriBuilder(baseURl);
builder.Path = "api/v1/catalog/items"; builder.Path = "api/v1/catalog/items";
@ -82,8 +82,8 @@ namespace eShopOnContainers.Core.Services.Catalog
{ {
try try
{ {
// TODO:
UriBuilder builder = new UriBuilder("http://catalog.api:5101");
var baseURl = System.Configuration.ConfigurationManager.AppSettings["CatalogURL"];
UriBuilder builder = new UriBuilder(baseURl);
builder.Path = "api/v1/catalog/catalogbrands"; builder.Path = "api/v1/catalog/catalogbrands";
@ -107,8 +107,8 @@ namespace eShopOnContainers.Core.Services.Catalog
{ {
try try
{ {
// TODO:
UriBuilder builder = new UriBuilder("http://catalog.api:5101");
var baseURl = System.Configuration.ConfigurationManager.AppSettings["CatalogURL"];
UriBuilder builder = new UriBuilder(baseURl);
builder.Path = "api/v1/catalog/catalogtypes"; builder.Path = "api/v1/catalog/catalogtypes";
@ -130,8 +130,8 @@ namespace eShopOnContainers.Core.Services.Catalog
public Task DeleteCatalogItemAsync(string catalogItemId) public Task DeleteCatalogItemAsync(string catalogItemId)
{ {
// TODO:
UriBuilder builder = new UriBuilder("http://catalog.api:5101");
var baseURl = System.Configuration.ConfigurationManager.AppSettings["CatalogURL"];
UriBuilder builder = new UriBuilder(baseURl);
builder.Path = $"api/v1/catalog/{catalogItemId}"; builder.Path = $"api/v1/catalog/{catalogItemId}";
@ -142,8 +142,8 @@ namespace eShopOnContainers.Core.Services.Catalog
public Task<CatalogItem> UpdateCatalogItemAsync(CatalogItem item) public Task<CatalogItem> UpdateCatalogItemAsync(CatalogItem item)
{ {
// TODO:
UriBuilder builder = new UriBuilder("http://catalog.api:5101");
var baseURl = System.Configuration.ConfigurationManager.AppSettings["CatalogURL"];
UriBuilder builder = new UriBuilder(baseURl);
builder.Path = "api/v1/catalog/edit"; builder.Path = "api/v1/catalog/edit";
@ -154,8 +154,8 @@ namespace eShopOnContainers.Core.Services.Catalog
public Task<CatalogItem> CreateCatalogItemAsync(CatalogItem item) public Task<CatalogItem> CreateCatalogItemAsync(CatalogItem item)
{ {
// TODO:
UriBuilder builder = new UriBuilder("http://catalog.api:5101");
var baseURl = System.Configuration.ConfigurationManager.AppSettings["CatalogURL"];
UriBuilder builder = new UriBuilder(baseURl);
builder.Path = "api/v1/catalog/create"; builder.Path = "api/v1/catalog/create";


+ 1
- 0
src/Web/Catalog.WebForms/Catalog.WebForms/Web.config View File

@ -10,6 +10,7 @@
</configSections> </configSections>
<appSettings> <appSettings>
<add key="usefake" value="false" /> <add key="usefake" value="false" />
<add key ="CatalogURL" value="http://catalog.api:5101" />
</appSettings> </appSettings>
<connectionStrings> <connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-Catalog.WebForms-20170322110716.mdf;Initial Catalog=aspnet-Catalog.WebForms-20170322110716;Integrated Security=True" providerName="System.Data.SqlClient" /> <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-Catalog.WebForms-20170322110716.mdf;Initial Catalog=aspnet-Catalog.WebForms-20170322110716;Integrated Security=True" providerName="System.Data.SqlClient" />


Loading…
Cancel
Save