Add counts to Dashboard (#2)

Also refactored database parameters with a few extension methods; ready for profile view page
This commit is contained in:
2021-01-04 23:05:53 -05:00
parent fe3510b818
commit 97b3de1cea
15 changed files with 325 additions and 93 deletions

View File

@@ -1,4 +1,5 @@
using JobsJobsJobs.Shared;
using Blazored.Toast.Services;
using JobsJobsJobs.Shared;
using JobsJobsJobs.Shared.Api;
using Microsoft.AspNetCore.Components;
using System.Collections.Generic;
@@ -51,6 +52,12 @@ namespace JobsJobsJobs.Client.Pages.Citizen
[Inject]
private AppState State { get; set; } = default!;
/// <summary>
/// Toast service
/// </summary>
[Inject]
private IToastService Toasts { get; set; } = default!;
protected override async Task OnInitializedAsync()
{
ServerApi.SetJwt(Http, State);
@@ -128,12 +135,13 @@ namespace JobsJobsJobs.Client.Pages.Citizen
var res = await Http.PostAsJsonAsync("/api/profile/save", ProfileForm);
if (res.IsSuccessStatusCode)
{
// TODO: success notification
Toasts.ShowSuccess("Profile Saved Successfully");
}
else
{
// TODO: probably not the best way to handle this...
ErrorMessages.Add(await res.Content.ReadAsStringAsync());
var error = await res.Content.ReadAsStringAsync();
if (!string.IsNullOrEmpty(error)) error = $"- {error}";
Toasts.ShowError($"{(int)res.StatusCode} {error}");
}
}