Remove old references and refactor base controller
This commit is contained in:
		| @@ -1,4 +1,5 @@ | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Newtonsoft.Json; | ||||
| using Refit; | ||||
|  | ||||
| @@ -23,8 +24,25 @@ namespace Core.Cerberos.BFF.Api.Controllers | ||||
|  | ||||
|         private IActionResult FromAPIResponse<T>(ApiResponse<T> response) where T : class | ||||
|         { | ||||
|             var errorContent = JsonConvert.DeserializeObject<string>(response.Error?.Content ?? string.Empty) ?? string.Empty; | ||||
|             return StatusCode((int)response.StatusCode, (response.Content is not null) ? response.Content : errorContent); | ||||
|             if (response.IsSuccessful) | ||||
|                 return StatusCode((int)response.StatusCode, response.Content); | ||||
|             else | ||||
|             { | ||||
|                 dynamic errorContent = string.Empty; | ||||
|  | ||||
|                 try | ||||
|                 { | ||||
|                     errorContent = JsonConvert.DeserializeObject<string>(response.Error?.Content ?? string.Empty) ?? string.Empty; | ||||
|                 } | ||||
|                 catch (Exception) | ||||
|                 { | ||||
|                     errorContent = JsonConvert.DeserializeObject<HttpError>(response.Error?.Content); | ||||
|                     if (errorContent?.Error?.ErrorCode is null && errorContent?.Error?.Message is null && errorContent?.Error?.Target is null) | ||||
|                         errorContent = JsonConvert.DeserializeObject<GenericErrorResponse>(response.Error?.Content); | ||||
|  | ||||
|                 } | ||||
|                 return StatusCode((int)response.StatusCode, errorContent); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -7,8 +7,8 @@ | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="BuildingBlocks.Library" Version="0.0.1" /> | ||||
|     <PackageReference Include="Cerberos.Building.Blocks" Version="0.0.3" /> | ||||
|     <PackageReference Include="Lib.Architecture.BuildingBlocks" Version="0.9.0-alpha0001" /> | ||||
|     <PackageReference Include="Refit" Version="8.0.0" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sergio Matias Urquin
					Sergio Matias Urquin