Skip to content

Commit 2080c0f

Browse files
author
David Paquette
committed
2 parents d07f774 + 13bd293 commit 2080c0f

File tree

6 files changed

+229
-135
lines changed

6 files changed

+229
-135
lines changed

2wr-app/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,26 @@ For many years, we’ve been talking about the importance of being prepared for
2929
**Use this application as a means to prepare to become two weeks ready.**
3030

3131
For additional details, questions, etc. You can reach out out to Pascal @schuback or Richard @richcampbell on twitter and/or join our hackathon dev channel on slack (https://join.slack.com/share/enQtMzE4MjQ4MTUzMzM2Ny0yNWE1OGJlMGIwNDJmMTI5MTEyYTVmMDViNzBmMThjYzkyOTk3ZDQwNTgyZGU1YjI3ZTA3ZmEyZjU5MDU1MGRk). (LINK posted 3/5 and expires 14 days after)
32+
33+
## Getting Started
34+
This project is configured to work with DevContainers/Codespaces to get developers up and running as quickly as possible. For DevContainers, all you need is [Docker][2] installed and you should be good to go! For Codespaces, you will need a GitHub account wiht Codespaces enabled.
35+
36+
To see a full demo on how to setup your DevContainer/Codespaces environment, check out [this video][1] from @davidwesst where he walks through setting up HTBox/TwoWeeksReady, executing the various development tasks, and provides an overview about DevContainers and Codespaces.
37+
38+
To setup your own development environment from scratch or to install the dependendies locally, refer to the files [`.devcontainer/devcontainer.json`](https://github.com/HTBox/TwoWeeksReady/blob/main/.devcontainer/devcontainer.json) and [`.devcontainer/Dockerfile`](https://github.com/HTBox/TwoWeeksReady/blob/main/.devcontainer/devcontainer.json) to understand what tools are required.
39+
40+
## Solution Architecture
41+
42+
![Architecture of Two Weeks Ready](https://user-images.githubusercontent.com/2531875/168096742-0b29eee3-b3e1-4485-9d77-c095cb6a9f2e.png)
43+
44+
45+
### Resources
46+
- [Tutorial Video from @davidwesst][1]
47+
- [Docker Desktop][2]
48+
- [Developing with VSCode and DevContainers][3]
49+
- [Developing with VSCode and GitHub Codespaces][4]
50+
51+
[1]: https://www.youtube.com/watch?v=rYfsNBODfZc
52+
[2]: https://www.docker.com/products/personal/
53+
[3]: https://code.visualstudio.com/docs/remote/containers#_quick-start-try-a-development-container
54+
[4]: https://code.visualstudio.com/docs/remote/codespaces

admin/TwoWeeksReady.Admin/Components/KitItemDisplay.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
public async Task Save()
5656
{
5757
IsEditMode = false;
58-
await repository.SaveBaseKitItem(Item);
58+
@* await repository.SaveBaseKitItem(Item); *@
5959
await OnSave.InvokeAsync(Item);
6060

6161
}

admin/TwoWeeksReady.Admin/Data/FunctionsRepository.cs

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ public FunctionsRepository(IHttpClientFactory httpClientFactory, TokenProvider t
2020
_tokenProvider = tokenProvider;
2121
this._httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokenProvider.AccessToken);
2222
}
23-
public Task<IEnumerable<BaseKit>> GetAllBaseKits()
23+
24+
public async Task<IEnumerable<BaseKit>> GetAllBaseKits()
2425
{
25-
throw new NotImplementedException();
26+
return await _httpClient.GetFromJsonAsync<IList<BaseKit>>("basekits");
2627
}
2728

2829
public async Task<IEnumerable<HazardHunt>> GetAllHazardHunts()
@@ -35,9 +36,9 @@ public async Task<IEnumerable<HazardInfo>> GetAllHazardInfos()
3536
return await _httpClient.GetFromJsonAsync<IList<HazardInfo>>("hazardinfo-list");
3637
}
3738

38-
public Task<BaseKit> GetBaseKitById(string id)
39+
public async Task<BaseKit> GetBaseKitById(string id)
3940
{
40-
throw new NotImplementedException();
41+
return await _httpClient.GetFromJsonAsync<BaseKit>($"basekit-by-id/{id}");
4142
}
4243

4344
public async Task<HazardHunt> GetHazardHuntById(string id)
@@ -50,9 +51,17 @@ public async Task<HazardInfo> GetHazardInfoById(string id)
5051
return await _httpClient.GetFromJsonAsync<HazardInfo>($"hazardinfo-by-id/{id}");
5152
}
5253

53-
public Task<BaseKitItem> SaveBaseKitItem(BaseKitItem kit)
54+
public async Task<BaseKit> SaveBaseKit(BaseKit kit)
5455
{
55-
throw new NotImplementedException();
56+
var response = await _httpClient.PutAsJsonAsync("basekits-update", kit);
57+
if (response.IsSuccessStatusCode)
58+
{
59+
return await response.Content.ReadFromJsonAsync<BaseKit>();
60+
}
61+
else
62+
{
63+
throw new Exception("Error saving base kit");
64+
}
5665
}
5766

5867
public async Task<HazardHunt> SaveHazardHunt(HazardHunt hazardHunt)
@@ -74,14 +83,26 @@ public async Task<HazardInfo> SaveHazardInfo(HazardInfo hazardInfo)
7483
if (response.IsSuccessStatusCode)
7584
{
7685
return await response.Content.ReadFromJsonAsync<HazardInfo>();
77-
}
86+
}
7887
else
7988
{
8089
throw new Exception("Error saving hazard info");
8190
}
8291
}
8392

84-
93+
public async Task<BaseKit> CreateBaseKit(BaseKit kit)
94+
{
95+
var response = await _httpClient.PostAsJsonAsync("basekit-create", kit);
96+
if (response.IsSuccessStatusCode)
97+
{
98+
return await response.Content.ReadFromJsonAsync<BaseKit>();
99+
}
100+
else
101+
{
102+
throw new Exception("Error saving base kit");
103+
}
104+
}
105+
85106
public async Task<HazardInfo> CreateHazardInfo(HazardInfo hazardInfo)
86107
{
87108
var response = await _httpClient.PostAsJsonAsync("hazardinfo-create", hazardInfo);
@@ -107,5 +128,44 @@ public async Task<HazardHunt> CreateHazardHunt(HazardHunt hazardHunt)
107128
throw new Exception("Error saving hazard hunt");
108129
}
109130
}
131+
132+
public async Task<bool> DeleteBaseKit(string id)
133+
{
134+
var response = await _httpClient.DeleteAsync($"basekit-delete/{id}");
135+
if (response.IsSuccessStatusCode)
136+
{
137+
return true;
138+
}
139+
else
140+
{
141+
throw new Exception("Error deleting base kit");
142+
}
143+
}
144+
145+
public async Task<bool> DeleteHazardHunt(string id)
146+
{
147+
var response = await _httpClient.DeleteAsync($"hazardhunt-delete/{id}");
148+
if (response.IsSuccessStatusCode)
149+
{
150+
return true;
151+
}
152+
else
153+
{
154+
throw new Exception("Error deleting hazard hunt");
155+
}
156+
}
157+
158+
public async Task<bool> DeleteHazardInfo(string id)
159+
{
160+
var response = await _httpClient.DeleteAsync($"hazardinfo-delete/{id}");
161+
if (response.IsSuccessStatusCode)
162+
{
163+
return true;
164+
}
165+
else
166+
{
167+
throw new Exception("Error deleting hazard info");
168+
}
169+
}
110170
}
111171
}

admin/TwoWeeksReady.Admin/Data/IRepository.cs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,24 @@
55
namespace TwoWeeksReady.Admin.Data
66
{
77
public interface IRepository
8-
{
9-
10-
Task<BaseKit> GetBaseKitById(string id);
11-
12-
Task<IEnumerable<BaseKit>> GetAllBaseKits();
13-
14-
Task<BaseKitItem> SaveBaseKitItem(BaseKitItem kit);
15-
16-
Task<IEnumerable<HazardHunt>> GetAllHazardHunts();
17-
18-
Task<HazardHunt> GetHazardHuntById(string id);
19-
20-
Task<HazardHunt> SaveHazardHunt(HazardHunt hazardHunt);
21-
22-
Task<IEnumerable<HazardInfo>> GetAllHazardInfos();
23-
24-
Task<HazardInfo> GetHazardInfoById(string id);
25-
26-
Task<HazardInfo> SaveHazardInfo(HazardInfo hazardInfo);
27-
28-
Task<HazardInfo> CreateHazardInfo(HazardInfo hazardInfo);
29-
30-
Task<HazardHunt> CreateHazardHunt(HazardHunt hazardHunt);
31-
}
8+
{
9+
Task<IEnumerable<BaseKit>> GetAllBaseKits();
10+
Task<BaseKit> GetBaseKitById(string id);
11+
Task<BaseKit> CreateBaseKit(BaseKit kit);
12+
Task<BaseKit> SaveBaseKit(BaseKit kit);
13+
Task<bool> DeleteBaseKit(string id);
14+
15+
Task<IEnumerable<HazardHunt>> GetAllHazardHunts();
16+
Task<HazardHunt> GetHazardHuntById(string id);
17+
Task<HazardHunt> CreateHazardHunt(HazardHunt hazardHunt);
18+
Task<HazardHunt> SaveHazardHunt(HazardHunt hazardHunt);
19+
Task<bool> DeleteHazardHunt(string id);
20+
21+
Task<IEnumerable<HazardInfo>> GetAllHazardInfos();
22+
Task<HazardInfo> GetHazardInfoById(string id);
23+
Task<HazardInfo> CreateHazardInfo(HazardInfo hazardInfo);
24+
Task<HazardInfo> SaveHazardInfo(HazardInfo hazardInfo);
25+
Task<bool> DeleteHazardInfo(string id);
26+
}
3227

3328
}

0 commit comments

Comments
 (0)