-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #316 from GregFinzer/FixAddLocation
Big fix for add location
- Loading branch information
Showing
23 changed files
with
853 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1 @@ | ||
@using Serilog | ||
|
||
@((MarkupString)footerContent) | ||
|
||
@code { | ||
// Client | ||
private string footerContent = string.Empty; | ||
[Inject] private IContentDataService _svcContent { get; set; } | ||
[Inject] private ILocationDataService _svcLocation { get; set; } | ||
[Inject] NavigationManager _nm { get; set; } | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
try | ||
{ | ||
|
||
var contentResult = await _svcContent.GetAsync("Footer", (int)LocationNumber.National); | ||
if (contentResult.Success) | ||
{ | ||
footerContent = contentResult.Data.ContentHtml; | ||
} | ||
else | ||
{ | ||
Log.Logger.Error($"Error getting footer content: {contentResult.Message}"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.Logger.Error(ex, $"Footer.OnInitializedAsync : {ex.Message}"); | ||
throw; | ||
} | ||
} | ||
} | ||
@((MarkupString)footerContent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using BedBrigade.Client.Services; | ||
using BedBrigade.Data.Services; | ||
using Microsoft.AspNetCore.Components; | ||
using Serilog; | ||
|
||
namespace BedBrigade.Client.Components | ||
{ | ||
public partial class Footer : ComponentBase, IDisposable | ||
{ | ||
// Client | ||
private string footerContent = string.Empty; | ||
[Inject] private IContentDataService _svcContent { get; set; } | ||
[Inject] private ILocationDataService _svcLocation { get; set; } | ||
[Inject] NavigationManager _nm { get; set; } | ||
[Inject] private IFooterLocationState _locationState { get; set; } | ||
private string PreviousLocation { get; set; } | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
await LoadContent(); | ||
_locationState.OnChange += OnLocationChanged; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_locationState.OnChange -= OnLocationChanged; | ||
} | ||
|
||
private async Task LoadContent() | ||
{ | ||
string locationName = _locationState.Location ?? "national"; | ||
var locationResult = await _svcLocation.GetLocationByRouteAsync($"/{locationName.ToLower()}"); | ||
|
||
if (!locationResult.Success) | ||
{ | ||
Log.Logger.Error($"Error loading Footer location: {locationResult.Message}"); | ||
} | ||
else | ||
{ | ||
var contentResult = await _svcContent.GetAsync("Footer", locationResult.Data.LocationId); | ||
|
||
if (contentResult.Success) | ||
{ | ||
footerContent = contentResult.Data.ContentHtml; | ||
PreviousLocation = locationName; | ||
} | ||
else | ||
{ | ||
Log.Logger.Error($"Error loading Footer for LocationId {locationResult.Data.LocationId}: {contentResult.Message}"); | ||
} | ||
} | ||
} | ||
|
||
private async void OnLocationChanged() | ||
{ | ||
await LoadContent(); | ||
StateHasChanged(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
This is the header | ||
@((MarkupString)headerContent) | ||
@((MarkupString)headerContent) | ||
|
||
|
||
<style> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace BedBrigade.Client.Services | ||
{ | ||
public class FooterLocationState : IFooterLocationState | ||
{ | ||
private string _location; | ||
public string Location | ||
{ | ||
get => _location; | ||
set | ||
{ | ||
if (_location != value) | ||
{ | ||
_location = value; | ||
NotifyStateChanged(); | ||
} | ||
} | ||
} | ||
|
||
public event Action OnChange; | ||
|
||
private void NotifyStateChanged() => OnChange?.Invoke(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace BedBrigade.Client.Services | ||
{ | ||
public class HeaderLocationState : IHeaderLocationState | ||
{ | ||
private string _location; | ||
public string Location | ||
{ | ||
get => _location; | ||
set | ||
{ | ||
if (_location != value) | ||
{ | ||
_location = value; | ||
NotifyStateChanged(); | ||
} | ||
} | ||
} | ||
|
||
public event Action OnChange; | ||
|
||
private void NotifyStateChanged() => OnChange?.Invoke(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace BedBrigade.Client.Services | ||
{ | ||
public interface IFooterLocationState | ||
{ | ||
string Location { get; set; } | ||
event Action OnChange; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace BedBrigade.Client.Services | ||
{ | ||
public interface IHeaderLocationState | ||
{ | ||
string Location { get; set; } | ||
event Action OnChange; | ||
} | ||
} |
Oops, something went wrong.