Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
David Paquette committed May 12, 2022
2 parents d07f774 + 13bd293 commit 2080c0f
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 135 deletions.
12 changes: 6 additions & 6 deletions 2wr-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,26 @@ For many years, we’ve been talking about the importance of being prepared for
**Use this application as a means to prepare to become two weeks ready.**

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)

## Getting Started
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.

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.

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.

## Solution Architecture

![Architecture of Two Weeks Ready](https://user-images.githubusercontent.com/2531875/168096742-0b29eee3-b3e1-4485-9d77-c095cb6a9f2e.png)


### Resources
- [Tutorial Video from @davidwesst][1]
- [Docker Desktop][2]
- [Developing with VSCode and DevContainers][3]
- [Developing with VSCode and GitHub Codespaces][4]

[1]: https://www.youtube.com/watch?v=rYfsNBODfZc
[2]: https://www.docker.com/products/personal/
[3]: https://code.visualstudio.com/docs/remote/containers#_quick-start-try-a-development-container
[4]: https://code.visualstudio.com/docs/remote/codespaces
2 changes: 1 addition & 1 deletion admin/TwoWeeksReady.Admin/Components/KitItemDisplay.razor
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
public async Task Save()
{
IsEditMode = false;
await repository.SaveBaseKitItem(Item);
@* await repository.SaveBaseKitItem(Item); *@
await OnSave.InvokeAsync(Item);

}
Expand Down
76 changes: 68 additions & 8 deletions admin/TwoWeeksReady.Admin/Data/FunctionsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public FunctionsRepository(IHttpClientFactory httpClientFactory, TokenProvider t
_tokenProvider = tokenProvider;
this._httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokenProvider.AccessToken);
}
public Task<IEnumerable<BaseKit>> GetAllBaseKits()

public async Task<IEnumerable<BaseKit>> GetAllBaseKits()
{
throw new NotImplementedException();
return await _httpClient.GetFromJsonAsync<IList<BaseKit>>("basekits");
}

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

public Task<BaseKit> GetBaseKitById(string id)
public async Task<BaseKit> GetBaseKitById(string id)
{
throw new NotImplementedException();
return await _httpClient.GetFromJsonAsync<BaseKit>($"basekit-by-id/{id}");
}

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

public Task<BaseKitItem> SaveBaseKitItem(BaseKitItem kit)
public async Task<BaseKit> SaveBaseKit(BaseKit kit)
{
throw new NotImplementedException();
var response = await _httpClient.PutAsJsonAsync("basekits-update", kit);
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadFromJsonAsync<BaseKit>();
}
else
{
throw new Exception("Error saving base kit");
}
}

public async Task<HazardHunt> SaveHazardHunt(HazardHunt hazardHunt)
Expand All @@ -74,14 +83,26 @@ public async Task<HazardInfo> SaveHazardInfo(HazardInfo hazardInfo)
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadFromJsonAsync<HazardInfo>();
}
}
else
{
throw new Exception("Error saving hazard info");
}
}


public async Task<BaseKit> CreateBaseKit(BaseKit kit)
{
var response = await _httpClient.PostAsJsonAsync("basekit-create", kit);
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadFromJsonAsync<BaseKit>();
}
else
{
throw new Exception("Error saving base kit");
}
}

public async Task<HazardInfo> CreateHazardInfo(HazardInfo hazardInfo)
{
var response = await _httpClient.PostAsJsonAsync("hazardinfo-create", hazardInfo);
Expand All @@ -107,5 +128,44 @@ public async Task<HazardHunt> CreateHazardHunt(HazardHunt hazardHunt)
throw new Exception("Error saving hazard hunt");
}
}

public async Task<bool> DeleteBaseKit(string id)
{
var response = await _httpClient.DeleteAsync($"basekit-delete/{id}");
if (response.IsSuccessStatusCode)
{
return true;
}
else
{
throw new Exception("Error deleting base kit");
}
}

public async Task<bool> DeleteHazardHunt(string id)
{
var response = await _httpClient.DeleteAsync($"hazardhunt-delete/{id}");
if (response.IsSuccessStatusCode)
{
return true;
}
else
{
throw new Exception("Error deleting hazard hunt");
}
}

public async Task<bool> DeleteHazardInfo(string id)
{
var response = await _httpClient.DeleteAsync($"hazardinfo-delete/{id}");
if (response.IsSuccessStatusCode)
{
return true;
}
else
{
throw new Exception("Error deleting hazard info");
}
}
}
}
43 changes: 19 additions & 24 deletions admin/TwoWeeksReady.Admin/Data/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,24 @@
namespace TwoWeeksReady.Admin.Data
{
public interface IRepository
{

Task<BaseKit> GetBaseKitById(string id);

Task<IEnumerable<BaseKit>> GetAllBaseKits();

Task<BaseKitItem> SaveBaseKitItem(BaseKitItem kit);

Task<IEnumerable<HazardHunt>> GetAllHazardHunts();

Task<HazardHunt> GetHazardHuntById(string id);

Task<HazardHunt> SaveHazardHunt(HazardHunt hazardHunt);

Task<IEnumerable<HazardInfo>> GetAllHazardInfos();

Task<HazardInfo> GetHazardInfoById(string id);

Task<HazardInfo> SaveHazardInfo(HazardInfo hazardInfo);

Task<HazardInfo> CreateHazardInfo(HazardInfo hazardInfo);

Task<HazardHunt> CreateHazardHunt(HazardHunt hazardHunt);
}
{
Task<IEnumerable<BaseKit>> GetAllBaseKits();
Task<BaseKit> GetBaseKitById(string id);
Task<BaseKit> CreateBaseKit(BaseKit kit);
Task<BaseKit> SaveBaseKit(BaseKit kit);
Task<bool> DeleteBaseKit(string id);

Task<IEnumerable<HazardHunt>> GetAllHazardHunts();
Task<HazardHunt> GetHazardHuntById(string id);
Task<HazardHunt> CreateHazardHunt(HazardHunt hazardHunt);
Task<HazardHunt> SaveHazardHunt(HazardHunt hazardHunt);
Task<bool> DeleteHazardHunt(string id);

Task<IEnumerable<HazardInfo>> GetAllHazardInfos();
Task<HazardInfo> GetHazardInfoById(string id);
Task<HazardInfo> CreateHazardInfo(HazardInfo hazardInfo);
Task<HazardInfo> SaveHazardInfo(HazardInfo hazardInfo);
Task<bool> DeleteHazardInfo(string id);
}

}
Loading

0 comments on commit 2080c0f

Please sign in to comment.