diff --git a/src/BlazorAdmin/BlazorAdmin.csproj b/src/BlazorAdmin/BlazorAdmin.csproj
index 0193727..f02d879 100644
--- a/src/BlazorAdmin/BlazorAdmin.csproj
+++ b/src/BlazorAdmin/BlazorAdmin.csproj
@@ -14,7 +14,6 @@
-
diff --git a/src/BlazorAdmin/Helpers/BlazorLayoutComponent.cs b/src/BlazorAdmin/Helpers/BlazorLayoutComponent.cs
index b34e473..ca051f8 100644
--- a/src/BlazorAdmin/Helpers/BlazorLayoutComponent.cs
+++ b/src/BlazorAdmin/Helpers/BlazorLayoutComponent.cs
@@ -1,6 +1,4 @@
-using System.Threading.Tasks;
-using BlazorAdmin.Services;
-using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components;
namespace BlazorAdmin.Helpers
{
diff --git a/src/BlazorAdmin/JavaScript/JSInteropConstants.cs b/src/BlazorAdmin/JavaScript/JSInteropConstants.cs
index 3f1ae39..44c4dad 100644
--- a/src/BlazorAdmin/JavaScript/JSInteropConstants.cs
+++ b/src/BlazorAdmin/JavaScript/JSInteropConstants.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace BlazorAdmin.JavaScript
+namespace BlazorAdmin.JavaScript
{
public static class JSInteropConstants
{
diff --git a/src/BlazorAdmin/Pages/CatalogItemPage/List.razor b/src/BlazorAdmin/Pages/CatalogItemPage/List.razor
index f0e95df..217d94d 100644
--- a/src/BlazorAdmin/Pages/CatalogItemPage/List.razor
+++ b/src/BlazorAdmin/Pages/CatalogItemPage/List.razor
@@ -1,6 +1,9 @@
@page "/admin"
@attribute [Authorize(Roles = BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS)]
@inject AuthService Auth
+@inject BlazorAdmin.Services.CatalogItemServices.ListPaged CatalogItemListPaged
+@inject BlazorAdmin.Services.CatalogTypeServices.List TypeList
+@inject BlazorAdmin.Services.CatalogBrandServices.List BrandList
@inherits BlazorAdmin.Helpers.BlazorComponent
@namespace BlazorAdmin.Pages.CatalogItemPage
diff --git a/src/BlazorAdmin/Pages/CatalogItemPage/List.razor.cs b/src/BlazorAdmin/Pages/CatalogItemPage/List.razor.cs
index 21cbe2d..18d434c 100644
--- a/src/BlazorAdmin/Pages/CatalogItemPage/List.razor.cs
+++ b/src/BlazorAdmin/Pages/CatalogItemPage/List.razor.cs
@@ -22,9 +22,9 @@ namespace BlazorAdmin.Pages.CatalogItemPage
{
if (firstRender)
{
- catalogItems = await new BlazorAdmin.Services.CatalogItemServices.ListPaged(Auth).HandleAsync(50);
- catalogTypes = await new BlazorAdmin.Services.CatalogTypeServices.List(Auth).HandleAsync();
- catalogBrands = await new BlazorAdmin.Services.CatalogBrandServices.List(Auth).HandleAsync();
+ catalogItems = await CatalogItemListPaged.HandleAsync(50);
+ catalogTypes = await TypeList.HandleAsync();
+ catalogBrands = await BrandList.HandleAsync();
CallRequestRefresh();
}
@@ -37,9 +37,9 @@ namespace BlazorAdmin.Pages.CatalogItemPage
await DetailsComponent.Open(id);
}
- private void CreateClick()
+ private async Task CreateClick()
{
- CreateComponent.Open();
+ await CreateComponent.Open();
}
private async Task EditClick(int id)
diff --git a/src/BlazorAdmin/Program.cs b/src/BlazorAdmin/Program.cs
index eace497..a2adbee 100644
--- a/src/BlazorAdmin/Program.cs
+++ b/src/BlazorAdmin/Program.cs
@@ -25,6 +25,8 @@ namespace BlazorAdmin
builder.Services.AddSingleton();
builder.Services.AddSingleton(sp => (CustomAuthStateProvider)sp.GetRequiredService());
+ builder.Services.AddBlazorServices();
+
await builder.Build().RunAsync();
}
}
diff --git a/src/BlazorAdmin/Services/AuthService.cs b/src/BlazorAdmin/Services/AuthService.cs
index 989a9a1..102a430 100644
--- a/src/BlazorAdmin/Services/AuthService.cs
+++ b/src/BlazorAdmin/Services/AuthService.cs
@@ -1,12 +1,10 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
-using System.Text;
using System.Threading.Tasks;
using BlazorAdmin.JavaScript;
using Blazored.LocalStorage;
using Microsoft.JSInterop;
-using Newtonsoft.Json;
using BlazorShared.Authorization;
namespace BlazorAdmin.Services
@@ -16,12 +14,10 @@ namespace BlazorAdmin.Services
private readonly HttpClient _httpClient;
private readonly ILocalStorageService _localStorage;
private readonly IJSRuntime _jSRuntime;
+ private static bool InDocker { get; set; }
public string ApiUrl => Constants.GetApiUrl(InDocker);
public string WebUrl => Constants.GetWebUrl(InDocker);
-
- private static bool InDocker { get; set; }
-
public bool IsLoggedIn { get; set; }
public string UserName { get; set; }
@@ -32,28 +28,9 @@ namespace BlazorAdmin.Services
_jSRuntime = jSRuntime;
}
- public async Task HttpGet(string uri)
+ public HttpClient GetHttpClient()
{
- return await _httpClient.GetAsync($"{ApiUrl}{uri}");
- }
-
- public async Task HttpDelete(string uri, int id)
- {
- return await _httpClient.DeleteAsync($"{ApiUrl}{uri}/{id}");
- }
-
- public async Task HttpPost(string uri, object dataToSend)
- {
- var content = ToJson(dataToSend);
-
- return await _httpClient.PostAsync($"{ApiUrl}{uri}", content);
- }
-
- public async Task HttpPut(string uri, object dataToSend)
- {
- var content = ToJson(dataToSend);
-
- return await _httpClient.PutAsync($"{ApiUrl}{uri}", content);
+ return _httpClient;
}
public async Task Logout()
@@ -108,11 +85,6 @@ namespace BlazorAdmin.Services
return (await _localStorage.GetItemAsync("inDocker")).ToLower() == "true";
}
- private StringContent ToJson(object obj)
- {
- return new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json");
- }
-
private async Task LogoutIdentityManager()
{
await _httpClient.PostAsync("Identity/Account/Logout", null);
diff --git a/src/BlazorAdmin/Services/CatalogBrandServices/List.cs b/src/BlazorAdmin/Services/CatalogBrandServices/List.cs
index 2cc2dec..454840a 100644
--- a/src/BlazorAdmin/Services/CatalogBrandServices/List.cs
+++ b/src/BlazorAdmin/Services/CatalogBrandServices/List.cs
@@ -1,45 +1,25 @@
using System.Collections.Generic;
using System.Linq;
-using System.Net;
+using System.Net.Http;
+using System.Net.Http.Json;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
-using Newtonsoft.Json;
namespace BlazorAdmin.Services.CatalogBrandServices
{
public class List
{
private readonly AuthService _authService;
+ private readonly HttpClient _httpClient;
- public List(AuthService authService)
+ public List(AuthService authService, HttpClient httpClient)
{
_authService = authService;
+ _httpClient = httpClient;
}
public async Task> HandleAsync()
{
- var brands = new List();
- if (!_authService.IsLoggedIn)
- {
- return brands;
- }
-
- try
- {
- var result = await _authService.HttpGet("catalog-brands");
- if (result.StatusCode != HttpStatusCode.OK)
- {
- return brands;
- }
-
- brands = JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync()).CatalogBrands;
- }
- catch (AccessTokenNotAvailableException)
- {
- return brands;
- }
-
- return brands;
+ return (await _httpClient.GetFromJsonAsync($"{_authService.ApiUrl}catalog-brands"))?.CatalogBrands;
}
public static string GetBrandName(IEnumerable brands, int brandId)
diff --git a/src/BlazorAdmin/Services/CatalogItemServices/CatalogItem.cs b/src/BlazorAdmin/Services/CatalogItemServices/CatalogItem.cs
index eb86857..a732225 100644
--- a/src/BlazorAdmin/Services/CatalogItemServices/CatalogItem.cs
+++ b/src/BlazorAdmin/Services/CatalogItemServices/CatalogItem.cs
@@ -17,11 +17,12 @@ namespace BlazorAdmin.Services.CatalogItemServices
[Required(ErrorMessage = "The Name field is required")]
public string Name { get; set; }
+ [Required(ErrorMessage = "The Description field is required")]
public string Description { get; set; }
// decimal(18,2)
[RegularExpression(@"^\d+(\.\d{0,2})*$", ErrorMessage = "The field Price must be a positive number with maximum two decimals.")]
- [Range(0, 9999999999999999.99)]
+ [Range(0.01, 1000)]
[DataType(DataType.Currency)]
public decimal Price { get; set; }
diff --git a/src/BlazorAdmin/Services/CatalogItemServices/Create.CreateCatalogItemRequest.cs b/src/BlazorAdmin/Services/CatalogItemServices/Create.CreateCatalogItemRequest.cs
index 28e1536..1c4a343 100644
--- a/src/BlazorAdmin/Services/CatalogItemServices/Create.CreateCatalogItemRequest.cs
+++ b/src/BlazorAdmin/Services/CatalogItemServices/Create.CreateCatalogItemRequest.cs
@@ -11,11 +11,12 @@ namespace BlazorAdmin.Services.CatalogItemServices
[Required(ErrorMessage = "The Name field is required")]
public string Name { get; set; } = string.Empty;
+ [Required(ErrorMessage = "The Description field is required")]
public string Description { get; set; } = string.Empty;
// decimal(18,2)
[RegularExpression(@"^\d+(\.\d{0,2})*$", ErrorMessage = "The field Price must be a positive number with maximum two decimals.")]
- [Range(0, 9999999999999999.99)]
+ [Range(0.01, 1000)]
[DataType(DataType.Currency)]
public decimal Price { get; set; } = 0;
diff --git a/src/BlazorAdmin/Services/CatalogItemServices/Create.CreateCatalogItemResult.cs b/src/BlazorAdmin/Services/CatalogItemServices/Create.CreateCatalogItemResult.cs
index f76fe3f..37cf03f 100644
--- a/src/BlazorAdmin/Services/CatalogItemServices/Create.CreateCatalogItemResult.cs
+++ b/src/BlazorAdmin/Services/CatalogItemServices/Create.CreateCatalogItemResult.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace BlazorAdmin.Services.CatalogItemServices
+namespace BlazorAdmin.Services.CatalogItemServices
{
public class CreateCatalogItemResult
{
diff --git a/src/BlazorAdmin/Services/CatalogItemServices/Create.cs b/src/BlazorAdmin/Services/CatalogItemServices/Create.cs
index 67e4abe..74b9cc8 100644
--- a/src/BlazorAdmin/Services/CatalogItemServices/Create.cs
+++ b/src/BlazorAdmin/Services/CatalogItemServices/Create.cs
@@ -1,31 +1,19 @@
-using System.Net;
-using System.Threading.Tasks;
-using Newtonsoft.Json;
+using System.Threading.Tasks;
namespace BlazorAdmin.Services.CatalogItemServices
{
public class Create
{
- private readonly AuthService _authService;
+ private readonly HttpService _httpService;
public Create(AuthService authService)
{
- _authService = authService;
+ _httpService = new HttpService(authService.GetHttpClient(), authService.ApiUrl);
}
public async Task HandleAsync(CreateCatalogItemRequest catalogItem)
{
- var catalogItemResult = new CatalogItem();
-
- var result = await _authService.HttpPost("catalog-items", catalogItem);
- if (result.StatusCode != HttpStatusCode.OK)
- {
- return catalogItemResult;
- }
-
- catalogItemResult = JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync()).CatalogItem;
-
- return catalogItemResult;
+ return (await _httpService.HttpPost("catalog-items", catalogItem)).CatalogItem;
}
}
}
diff --git a/src/BlazorAdmin/Services/CatalogItemServices/Delete.cs b/src/BlazorAdmin/Services/CatalogItemServices/Delete.cs
index eb20182..86f82b9 100644
--- a/src/BlazorAdmin/Services/CatalogItemServices/Delete.cs
+++ b/src/BlazorAdmin/Services/CatalogItemServices/Delete.cs
@@ -1,31 +1,19 @@
-using System.Net;
-using System.Threading.Tasks;
-using Newtonsoft.Json;
+using System.Threading.Tasks;
namespace BlazorAdmin.Services.CatalogItemServices
{
public class Delete
{
- private readonly AuthService _authService;
+ private readonly HttpService _httpService;
public Delete(AuthService authService)
{
- _authService = authService;
+ _httpService = new HttpService(authService.GetHttpClient(), authService.ApiUrl);
}
public async Task HandleAsync(int catalogItemId)
{
- var catalogItemResult = string.Empty;
-
- var result = await _authService.HttpDelete("catalog-items", catalogItemId);
- if (result.StatusCode != HttpStatusCode.OK)
- {
- return catalogItemResult;
- }
-
- catalogItemResult = JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync()).Status;
-
- return catalogItemResult;
+ return (await _httpService.HttpDelete("catalog-items", catalogItemId)).Status;
}
}
}
diff --git a/src/BlazorAdmin/Services/CatalogItemServices/Edit.cs b/src/BlazorAdmin/Services/CatalogItemServices/Edit.cs
index 98484f2..a5fd6d3 100644
--- a/src/BlazorAdmin/Services/CatalogItemServices/Edit.cs
+++ b/src/BlazorAdmin/Services/CatalogItemServices/Edit.cs
@@ -1,31 +1,19 @@
-using System.Net;
-using System.Threading.Tasks;
-using Newtonsoft.Json;
+using System.Threading.Tasks;
namespace BlazorAdmin.Services.CatalogItemServices
{
public class Edit
{
- private readonly AuthService _authService;
+ private readonly HttpService _httpService;
public Edit(AuthService authService)
{
- _authService = authService;
+ _httpService = new HttpService(authService.GetHttpClient(), authService.ApiUrl);
}
public async Task HandleAsync(CatalogItem catalogItem)
{
- var catalogItemResult = new CatalogItem();
-
- var result = await _authService.HttpPut("catalog-items", catalogItem);
- if (result.StatusCode != HttpStatusCode.OK)
- {
- return catalogItemResult;
- }
-
- catalogItemResult = JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync()).CatalogItem;
-
- return catalogItemResult;
+ return (await _httpService.HttpPut("catalog-items", catalogItem)).CatalogItem;
}
}
}
diff --git a/src/BlazorAdmin/Services/CatalogItemServices/GetById.cs b/src/BlazorAdmin/Services/CatalogItemServices/GetById.cs
index ee1907a..01347f3 100644
--- a/src/BlazorAdmin/Services/CatalogItemServices/GetById.cs
+++ b/src/BlazorAdmin/Services/CatalogItemServices/GetById.cs
@@ -1,31 +1,19 @@
-using System.Net;
-using System.Threading.Tasks;
-using Newtonsoft.Json;
+using System.Threading.Tasks;
namespace BlazorAdmin.Services.CatalogItemServices
{
public class GetById
{
- private readonly AuthService _authService;
+ private readonly HttpService _httpService;
public GetById(AuthService authService)
{
- _authService = authService;
+ _httpService = new HttpService(authService.GetHttpClient(), authService.ApiUrl);
}
public async Task HandleAsync(int catalogItemId)
{
- var catalogItemResult = new CatalogItem();
-
- var result = await _authService.HttpGet($"catalog-items/{catalogItemId}");
- if (result.StatusCode != HttpStatusCode.OK)
- {
- return catalogItemResult;
- }
-
- catalogItemResult = JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync()).CatalogItem;
-
- return catalogItemResult;
+ return (await _httpService.HttpGet($"catalog-items/{catalogItemId}")).CatalogItem;
}
}
}
diff --git a/src/BlazorAdmin/Services/CatalogItemServices/ListPaged.cs b/src/BlazorAdmin/Services/CatalogItemServices/ListPaged.cs
index 3db843d..85a1e10 100644
--- a/src/BlazorAdmin/Services/CatalogItemServices/ListPaged.cs
+++ b/src/BlazorAdmin/Services/CatalogItemServices/ListPaged.cs
@@ -1,32 +1,20 @@
using System.Collections.Generic;
-using System.Net;
using System.Threading.Tasks;
-using Newtonsoft.Json;
namespace BlazorAdmin.Services.CatalogItemServices
{
public class ListPaged
{
- private readonly AuthService _authService;
+ private readonly HttpService _httpService;
public ListPaged(AuthService authService)
{
- _authService = authService;
+ _httpService = new HttpService(authService.GetHttpClient(), authService.ApiUrl);
}
public async Task> HandleAsync(int pageSize)
{
- var catalogItems = new List();
-
- var result = await _authService.HttpGet($"catalog-items?PageSize={pageSize}");
- if (result.StatusCode != HttpStatusCode.OK)
- {
- return catalogItems;
- }
-
- catalogItems = JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync()).CatalogItems;
-
- return catalogItems;
+ return (await _httpService.HttpGet($"catalog-items?PageSize={pageSize}")).CatalogItems;
}
}
diff --git a/src/BlazorAdmin/Services/CatalogTypeServices/List.cs b/src/BlazorAdmin/Services/CatalogTypeServices/List.cs
index 7512a66..174fb80 100644
--- a/src/BlazorAdmin/Services/CatalogTypeServices/List.cs
+++ b/src/BlazorAdmin/Services/CatalogTypeServices/List.cs
@@ -1,46 +1,25 @@
using System.Collections.Generic;
using System.Linq;
-using System.Net;
+using System.Net.Http;
+using System.Net.Http.Json;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
-using Newtonsoft.Json;
namespace BlazorAdmin.Services.CatalogTypeServices
{
public class List
{
private readonly AuthService _authService;
+ private readonly HttpClient _httpClient;
- public List(AuthService authService)
+ public List(AuthService authService, HttpClient httpClient)
{
_authService = authService;
+ _httpClient = httpClient;
}
public async Task> HandleAsync()
{
- var types = new List();
-
- if (!_authService.IsLoggedIn)
- {
- return types;
- }
-
- try
- {
- var result = await _authService.HttpGet("catalog-types");
- if (result.StatusCode != HttpStatusCode.OK)
- {
- return types;
- }
-
- types = JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync()).CatalogTypes;
- }
- catch (AccessTokenNotAvailableException)
- {
- return types;
- }
-
- return types;
+ return (await _httpClient.GetFromJsonAsync($"{_authService.ApiUrl}catalog-types"))?.CatalogTypes;
}
public static string GetTypeName(IEnumerable types, int typeId)
diff --git a/src/BlazorAdmin/Services/HttpService.cs b/src/BlazorAdmin/Services/HttpService.cs
new file mode 100644
index 0000000..7344864
--- /dev/null
+++ b/src/BlazorAdmin/Services/HttpService.cs
@@ -0,0 +1,85 @@
+using System.Net.Http;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+
+namespace BlazorAdmin.Services
+{
+ public class HttpService
+ {
+ private readonly HttpClient _httpClient;
+ private readonly string _apiUrl;
+
+ public HttpService(HttpClient httpClient, string apiUrl)
+ {
+ _httpClient = httpClient;
+ _apiUrl = apiUrl;
+ }
+
+ public async Task HttpGet(string uri)
+ where T : class
+ {
+ var result = await _httpClient.GetAsync($"{_apiUrl}{uri}");
+ if (!result.IsSuccessStatusCode)
+ {
+ return null;
+ }
+
+ return await FromHttpResponseMessage(result);
+ }
+
+ public async Task HttpDelete(string uri, int id)
+ where T : class
+ {
+ var result = await _httpClient.DeleteAsync($"{_apiUrl}{uri}/{id}");
+ if (!result.IsSuccessStatusCode)
+ {
+ return null;
+ }
+
+ return await FromHttpResponseMessage(result);
+ }
+
+ public async Task HttpPost(string uri, object dataToSend)
+ where T : class
+ {
+ var content = ToJson(dataToSend);
+
+ var result = await _httpClient.PostAsync($"{_apiUrl}{uri}", content);
+ if (!result.IsSuccessStatusCode)
+ {
+ return null;
+ }
+
+ return await FromHttpResponseMessage(result);
+ }
+
+ public async Task HttpPut(string uri, object dataToSend)
+ where T : class
+ {
+ var content = ToJson(dataToSend);
+
+ var result = await _httpClient.PutAsync($"{_apiUrl}{uri}", content);
+ if (!result.IsSuccessStatusCode)
+ {
+ return null;
+ }
+
+ return await FromHttpResponseMessage(result);
+ }
+
+
+ private StringContent ToJson(object obj)
+ {
+ return new StringContent(JsonSerializer.Serialize(obj), Encoding.UTF8, "application/json");
+ }
+
+ private async Task FromHttpResponseMessage(HttpResponseMessage result)
+ {
+ return JsonSerializer.Deserialize(await result.Content.ReadAsStringAsync(), new JsonSerializerOptions
+ {
+ PropertyNameCaseInsensitive = true
+ });
+ }
+ }
+}
diff --git a/src/BlazorAdmin/ServicesConfiguration.cs b/src/BlazorAdmin/ServicesConfiguration.cs
new file mode 100644
index 0000000..dc13468
--- /dev/null
+++ b/src/BlazorAdmin/ServicesConfiguration.cs
@@ -0,0 +1,22 @@
+using BlazorAdmin.Services.CatalogItemServices;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace BlazorAdmin
+{
+ public static class ServicesConfiguration
+ {
+ public static IServiceCollection AddBlazorServices(this IServiceCollection service)
+ {
+ service.AddScoped();
+ service.AddScoped();
+ service.AddScoped();
+ service.AddScoped();
+ service.AddScoped();
+
+ service.AddScoped();
+ service.AddScoped();
+
+ return service;
+ }
+ }
+}
diff --git a/src/Infrastructure/Infrastructure.csproj b/src/Infrastructure/Infrastructure.csproj
index cb93bb3..c2ff1c9 100644
--- a/src/Infrastructure/Infrastructure.csproj
+++ b/src/Infrastructure/Infrastructure.csproj
@@ -12,7 +12,6 @@
-
diff --git a/src/Infrastructure/Services/WebFileSystem.cs b/src/Infrastructure/Services/WebFileSystem.cs
index d60a653..edd4c23 100644
--- a/src/Infrastructure/Services/WebFileSystem.cs
+++ b/src/Infrastructure/Services/WebFileSystem.cs
@@ -2,10 +2,10 @@
using System.IO;
using System.Net.Http;
using System.Text;
+using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using Microsoft.eShopWeb.Infrastructure.Data;
-using Newtonsoft.Json;
namespace Microsoft.eShopWeb.Infrastructure.Services
{
@@ -49,7 +49,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Services
DataBase64 = Convert.ToBase64String(fileData),
FileName = fileName
};
- var content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
+ var content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
using var message = await _httpClient.PostAsync(_url, content);
if (!message.IsSuccessStatusCode)
diff --git a/src/PublicApi/CatalogItemEndpoints/Update.UpdateCatalogItemRequest.cs b/src/PublicApi/CatalogItemEndpoints/Update.UpdateCatalogItemRequest.cs
index a12638a..d386fde 100644
--- a/src/PublicApi/CatalogItemEndpoints/Update.UpdateCatalogItemRequest.cs
+++ b/src/PublicApi/CatalogItemEndpoints/Update.UpdateCatalogItemRequest.cs
@@ -15,6 +15,7 @@ namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
[Required]
public string Name { get; set; }
public string PictureBase64 { get; set; }
+ public string PictureUri { get; set; }
public string PictureName { get; set; }
[Range(0.01, 10000)]
public decimal Price { get; set; }
diff --git a/src/PublicApi/CatalogItemEndpoints/Update.cs b/src/PublicApi/CatalogItemEndpoints/Update.cs
index ad17781..6abbbfc 100644
--- a/src/PublicApi/CatalogItemEndpoints/Update.cs
+++ b/src/PublicApi/CatalogItemEndpoints/Update.cs
@@ -42,7 +42,7 @@ namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
existingItem.UpdateBrand(request.CatalogBrandId);
existingItem.UpdateType(request.CatalogTypeId);
- if (string.IsNullOrEmpty(request.PictureBase64))
+ if (string.IsNullOrEmpty(request.PictureBase64) && string.IsNullOrEmpty(request.PictureUri))
{
existingItem.UpdatePictureUri(string.Empty);
}
diff --git a/src/Web/Startup.cs b/src/Web/Startup.cs
index f543879..091007b 100644
--- a/src/Web/Startup.cs
+++ b/src/Web/Startup.cs
@@ -19,6 +19,7 @@ using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Mime;
+using BlazorAdmin;
using BlazorAdmin.Services;
using Blazored.LocalStorage;
using Microsoft.AspNetCore.Authentication.Cookies;
@@ -149,6 +150,7 @@ namespace Microsoft.eShopWeb.Web
services.AddBlazoredLocalStorage();
services.AddServerSideBlazor();
services.AddScoped();
+ services.AddBlazorServices();
_services = services; // used to debug registered services
}