File tree Expand file tree Collapse file tree
admin/TwoWeeksReady.Admin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,14 +47,7 @@ public Task<HazardHunt> GetHazardHuntById(string id)
4747
4848 public async Task < HazardInfo > GetHazardInfoById ( string id )
4949 {
50- try
51- {
52- return await _httpClient . GetFromJsonAsync < HazardInfo > ( $ "hazardinfo-by-id/{ id } ") ;
53- } catch ( Exception ex )
54- {
55- return new HazardInfo ( ) ;
56- }
57-
50+ return await _httpClient . GetFromJsonAsync < HazardInfo > ( $ "hazardinfo-by-id/{ id } ") ;
5851 }
5952
6053 public Task < BaseKitItem > SaveBaseKitItem ( BaseKitItem kit )
@@ -67,9 +60,17 @@ public Task<HazardHunt> SaveHazardHunt(HazardHunt hazardHunt)
6760 throw new NotImplementedException ( ) ;
6861 }
6962
70- public Task < HazardInfo > SaveHazardInfo ( HazardInfo hazardInfo )
63+ public async Task < HazardInfo > SaveHazardInfo ( HazardInfo hazardInfo )
7164 {
72- throw new NotImplementedException ( ) ;
65+ var response = await _httpClient . PutAsJsonAsync ( "hazardinfo-update" , hazardInfo ) ;
66+ if ( response . IsSuccessStatusCode )
67+ {
68+ return await response . Content . ReadFromJsonAsync < HazardInfo > ( ) ;
69+ }
70+ else
71+ {
72+ throw new Exception ( "Error saving hazard info" ) ;
73+ }
7374 }
7475 }
7576}
Original file line number Diff line number Diff line change 1010}
1111else
1212{
13- <h3 >Details </h3 >
14- <label for =" name" >Hazard Name : </label >
15- <input type =" text" @bind =" @Hazard.Name" />
16- <br />
17- <label for =" description" >Short Description : </label >
18- <input type =" text" @bind =" @Hazard.Description" />
19- <span class =" btn btn-secondary float-right" style =" cursor : pointer " @onclick =" @Save" >Save </span >
2013
14+ <h3 >Details </h3 >
15+ <form >
16+ <div class =" form-group" >
17+ <label for =" name" >Hazard Name </label >
18+ <input type =" text" class =" form-control" name =" name" @bind =" @Hazard.Name" >
19+ </div >
20+ <div class =" form-group" >
21+ <label for =" description" >Short Description : </label >
22+ <textarea class =" form-control" name =" description" @bind =" @Hazard.Description" rows =" 5" ></textarea >
23+ </div >
24+ <div class =" form-group" >
25+ <label for =" iconUrl" >Icon Url </label >
26+ <input type =" text" class =" form-control" name =" iconUrl" @bind =" @Hazard.IconUrl" >
27+ </div >
28+ <div class =" form-group" >
29+ <label for =" mediaUrl" >Media Url </label >
30+ <input type =" text" class =" form-control" name =" mediaUrl" @bind =" @Hazard.MediaUrl" >
31+ </div >
32+ <button type =" submit" class =" btn btn-primary" @onclick =" @Save" >Submit </button >
33+ </form >
2134}
2235
2336@code {
3952
4053 public async Task Save ()
4154 {
42- await repository .SaveHazardInfo (Hazard );
43- await OnSave .InvokeAsync (Hazard );
55+ Hazard = await repository .SaveHazardInfo (Hazard );
56+ // await OnSave.InvokeAsync(Hazard);
4457
4558 await JS .InvokeVoidAsync (" alert" , new object [] { " Hazard Info Saved" });
4659
Original file line number Diff line number Diff line change @@ -60,7 +60,6 @@ public void ConfigureServices(IServiceCollection services)
6060 options . Scope . Clear ( ) ;
6161 options . Scope . Add ( "openid" ) ;
6262 options . Scope . Add ( "profile" ) ;
63- options . Scope . Add ( "roles" ) ;
6463
6564 options . CallbackPath = new PathString ( "/callback" ) ;
6665 options . ClaimsIssuer = "Auth0" ;
You can’t perform that action at this time.
0 commit comments