@@ -17,19 +17,19 @@ namespace MedicalSystem.FrontEnds.WebMvc.Controllers
17
17
public class ConsultationController : Controller
18
18
{
19
19
private readonly IHttpClientFactory _httpClientFactory ;
20
- private readonly ConsultationOptions _consultationOptions ;
20
+ private readonly IOptionsMonitor < ConsultationOptions > _consultationOptionsAccessor ;
21
21
22
22
public ConsultationController ( IHttpClientFactory httpClientFactory ,
23
23
IOptionsMonitor < ConsultationOptions > consultationOptionsAccessor )
24
24
{
25
25
_httpClientFactory = httpClientFactory ;
26
- _consultationOptions = consultationOptionsAccessor . CurrentValue ;
26
+ _consultationOptionsAccessor = consultationOptionsAccessor ;
27
27
}
28
28
29
29
public async Task < IActionResult > Index ( )
30
30
{
31
31
HttpClient httpClient = _httpClientFactory . CreateClient ( ) ;
32
- HttpResponseMessage consultationApiResponseMessage = await httpClient . GetAsync ( _consultationOptions . ConsultationGatewayUrl ) ;
32
+ HttpResponseMessage consultationApiResponseMessage = await httpClient . GetAsync ( _consultationOptionsAccessor . CurrentValue . ConsultationGatewayUrl ) ;
33
33
if ( consultationApiResponseMessage . IsSuccessStatusCode )
34
34
{
35
35
using Stream consultationApiResponseStream = await consultationApiResponseMessage . Content . ReadAsStreamAsync ( ) ;
@@ -53,7 +53,7 @@ public async Task<IActionResult> Details(int? id)
53
53
return RedirectToAction ( nameof ( Index ) ) ;
54
54
}
55
55
HttpClient httpClient = _httpClientFactory . CreateClient ( ) ;
56
- var consultationGetByIdGatewayUrl = $ "{ _consultationOptions . ConsultationGatewayUrl } /{ id } ";
56
+ var consultationGetByIdGatewayUrl = $ "{ _consultationOptionsAccessor . CurrentValue . ConsultationGatewayUrl } /{ id } ";
57
57
HttpResponseMessage consultationApiResponseMessage = await httpClient . GetAsync ( consultationGetByIdGatewayUrl ) ;
58
58
if ( consultationApiResponseMessage . StatusCode == HttpStatusCode . OK )
59
59
{
@@ -69,7 +69,7 @@ public async Task<IActionResult> Create()
69
69
HttpClient httpClient = _httpClientFactory . CreateClient ( ) ;
70
70
71
71
HttpResponseMessage consultationAddEditInitResponseMessage =
72
- await httpClient . GetAsync ( _consultationOptions . ConsultationGatewayAddEditInitDataUrl ) ;
72
+ await httpClient . GetAsync ( _consultationOptionsAccessor . CurrentValue . ConsultationGatewayAddEditInitDataUrl ) ;
73
73
if ( consultationAddEditInitResponseMessage . StatusCode != HttpStatusCode . OK )
74
74
{
75
75
return StatusCode ( ( int ) consultationAddEditInitResponseMessage . StatusCode ) ;
@@ -120,7 +120,7 @@ public async Task<IActionResult> Create(ConsultationModel consultation)
120
120
{
121
121
HttpClient httpClient = _httpClientFactory . CreateClient ( ) ;
122
122
var consultationContent = new StringContent ( JsonSerializer . Serialize ( consultation ) , Encoding . UTF8 , "application/json" ) ;
123
- HttpResponseMessage consultationApiResponseMessage = await httpClient . PostAsync ( _consultationOptions . ConsultationGatewayUrl , consultationContent ) ;
123
+ HttpResponseMessage consultationApiResponseMessage = await httpClient . PostAsync ( _consultationOptionsAccessor . CurrentValue . ConsultationGatewayUrl , consultationContent ) ;
124
124
if ( consultationApiResponseMessage . IsSuccessStatusCode )
125
125
{
126
126
return RedirectToAction ( nameof ( Index ) ) ;
@@ -135,15 +135,15 @@ public async Task<IActionResult> Edit(int? id)
135
135
return RedirectToAction ( nameof ( Index ) ) ;
136
136
}
137
137
HttpClient httpClient = _httpClientFactory . CreateClient ( ) ;
138
- var consultationGetByIdGatewayUrl = $ "{ _consultationOptions . ConsultationGatewayUrl } /{ id } ";
138
+ var consultationGetByIdGatewayUrl = $ "{ _consultationOptionsAccessor . CurrentValue . ConsultationGatewayUrl } /{ id } ";
139
139
HttpResponseMessage consultationApiResponseMessage = await httpClient . GetAsync ( consultationGetByIdGatewayUrl ) ;
140
140
if ( consultationApiResponseMessage . StatusCode == HttpStatusCode . OK )
141
141
{
142
142
using Stream consultationApiResponseStream = await consultationApiResponseMessage . Content . ReadAsStreamAsync ( ) ;
143
143
ConsultationModel ? consultationModel = await JsonSerializer . DeserializeAsync < ConsultationModel > ( consultationApiResponseStream ) ;
144
144
145
145
HttpResponseMessage consultationAddEditInitResponseMessage =
146
- await httpClient . GetAsync ( _consultationOptions . ConsultationGatewayAddEditInitDataUrl ) ;
146
+ await httpClient . GetAsync ( _consultationOptionsAccessor . CurrentValue . ConsultationGatewayAddEditInitDataUrl ) ;
147
147
if ( consultationAddEditInitResponseMessage . StatusCode != HttpStatusCode . OK )
148
148
{
149
149
return StatusCode ( ( int ) consultationAddEditInitResponseMessage . StatusCode ) ;
@@ -196,7 +196,7 @@ public async Task<IActionResult> Edit(int? id)
196
196
public async Task < IActionResult > Edit ( int id , ConsultationModel consultation )
197
197
{
198
198
HttpClient httpClient = _httpClientFactory . CreateClient ( ) ;
199
- var consultationUpdateGatewayUrl = $ "{ _consultationOptions . ConsultationGatewayUrl } /{ id } ";
199
+ var consultationUpdateGatewayUrl = $ "{ _consultationOptionsAccessor . CurrentValue . ConsultationGatewayUrl } /{ id } ";
200
200
var consultationContent = new StringContent ( JsonSerializer . Serialize ( consultation ) , Encoding . UTF8 , "application/json" ) ;
201
201
HttpResponseMessage consultationApiResponseMessage = await httpClient . PutAsync ( consultationUpdateGatewayUrl , consultationContent ) ;
202
202
if ( consultationApiResponseMessage . IsSuccessStatusCode )
@@ -209,7 +209,7 @@ public async Task<IActionResult> Edit(int id, ConsultationModel consultation)
209
209
public async Task < IActionResult > Delete ( int ? id )
210
210
{
211
211
HttpClient httpClient = _httpClientFactory . CreateClient ( ) ;
212
- var consultationDeleteGatewayUrl = $ "{ _consultationOptions . ConsultationGatewayUrl } /{ id } ";
212
+ var consultationDeleteGatewayUrl = $ "{ _consultationOptionsAccessor . CurrentValue . ConsultationGatewayUrl } /{ id } ";
213
213
HttpResponseMessage consultationApiResponseMessage = await httpClient . DeleteAsync ( consultationDeleteGatewayUrl ) ;
214
214
if ( consultationApiResponseMessage . IsSuccessStatusCode )
215
215
{
0 commit comments