Skip to content

Commit

Permalink
#218 - Using GetProfile query in <LoginInfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Feb 22, 2019
1 parent b107a4a commit 04cbab5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/Money.UI.Blazor/Layouts/LoginInfo.cshtml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@inject ApiClient Api
@inject IQueryDispatcher Queries
@inject Navigator Navigator

<form action="/account/logout" method="post" id="logoutForm" class="navbar-right">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="@Navigator.UrlUserManage()" onclick="@(() => Navigator.OpenUserManage())">
<Loading Context="@Loading">
User: @UserName
User: @Profile.UserName
</Loading>
</a>
</li>
Expand All @@ -18,15 +18,13 @@

@functions
{
public string UserName { get; private set; }
public ProfileModel Profile { get; private set; }

protected LoadingContext Loading { get; } = new LoadingContext();

protected override async Task OnInitAsync()
{
using (Loading.Start())
{
UserName = await Api.GetUserNameAsync();
}
Profile = await Queries.QueryAsync(new GetProfile());
}
}
3 changes: 0 additions & 3 deletions src/Money.UI.Blazor/Services/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public ApiClient(HttpClient http, CommandMapper commandMapper, QueryMapper query
this.queryMapper = queryMapper;
}

public Task<string> GetUserNameAsync()
=> http.GetStringAsync("/api/username");

public Task ChangeEmail(string email)
=> http.PostJsonAsync("/api/user/changeemail", email);

Expand Down
1 change: 1 addition & 0 deletions src/Money.UI.Blazor/_ViewImports.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@using Money.Models.Loading
@using Money.Pages
@using Money.Services
@using Money.Queries
@using Money.UI.Blazor
@using Neptuo
@using Neptuo.Commands
Expand Down

0 comments on commit 04cbab5

Please sign in to comment.