forked from dotnet-architecture/eShopOnWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shady nagy/remove newton soft (dotnet-architecture#436)
* replace NewtonSoft with System.Text.Json * not use auth for brande and types and use GetFromJsonAsync * fix * fix * Auth HttpGet more simple. * Put, Delete and Post more simple. * Fixed Edit for remove image and keep image and change other fields. Added description required in Blazor Admin. * Removed using not used * Refactor AuthService and introduce HttpService. add validation for price. * return null in HttpService if not success. * Limt Price to 1000 mximum * DI for Blazor Services * one blazor service. * fix
- Loading branch information
Showing
24 changed files
with
164 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
src/BlazorAdmin/Services/CatalogItemServices/Create.CreateCatalogItemResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CatalogItem> 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<CreateCatalogItemResult>(await result.Content.ReadAsStringAsync()).CatalogItem; | ||
|
||
return catalogItemResult; | ||
return (await _httpService.HttpPost<CreateCatalogItemResult>("catalog-items", catalogItem)).CatalogItem; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string> 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<DeleteCatalogItemResult>(await result.Content.ReadAsStringAsync()).Status; | ||
|
||
return catalogItemResult; | ||
return (await _httpService.HttpDelete<DeleteCatalogItemResult>("catalog-items", catalogItemId)).Status; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CatalogItem> 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<EditCatalogItemResult>(await result.Content.ReadAsStringAsync()).CatalogItem; | ||
|
||
return catalogItemResult; | ||
return (await _httpService.HttpPut<EditCatalogItemResult>("catalog-items", catalogItem)).CatalogItem; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CatalogItem> 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<EditCatalogItemResult>(await result.Content.ReadAsStringAsync()).CatalogItem; | ||
|
||
return catalogItemResult; | ||
return (await _httpService.HttpGet<EditCatalogItemResult>($"catalog-items/{catalogItemId}")).CatalogItem; | ||
} | ||
} | ||
} |
Oops, something went wrong.