Using a single GetUserName() temporary extension in all places where I try to get the user name. This temporary extension will go away when we have these extensions as part of identity package.
This commit is contained in:
parent
506b439f2f
commit
aa7fe89c81
|
|
@ -46,7 +46,7 @@ namespace MusicStore.Controllers
|
||||||
: 1;
|
: 1;
|
||||||
|
|
||||||
order.OrderId = nextId;
|
order.OrderId = nextId;
|
||||||
order.Username = this.Context.User.Identity.Name;
|
order.Username = this.Context.User.Identity.GetUserName();
|
||||||
order.OrderDate = DateTime.Now;
|
order.OrderDate = DateTime.Now;
|
||||||
|
|
||||||
//Add the Order
|
//Add the Order
|
||||||
|
|
@ -78,7 +78,7 @@ namespace MusicStore.Controllers
|
||||||
// Validate customer owns this order
|
// Validate customer owns this order
|
||||||
bool isValid = db.Orders.Any(
|
bool isValid = db.Orders.Any(
|
||||||
o => o.OrderId == id &&
|
o => o.OrderId == id &&
|
||||||
o.Username == this.Context.User.Identity.Name);
|
o.Username == this.Context.User.Identity.GetUserName());
|
||||||
|
|
||||||
if (isValid)
|
if (isValid)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
@using Microsoft.AspNet.Identity;
|
@*This using statement to MusicStore.Controllers should go away once we have the GetUserName() extension on IIdentity in some Identity package*@
|
||||||
|
@using MusicStore.Controllers
|
||||||
|
@using Microsoft.AspNet.Identity;
|
||||||
|
|
||||||
@if (Context.HttpContext.User != null && Context.HttpContext.User.Identity.IsAuthenticated)
|
@if (Context.HttpContext.User != null && Context.HttpContext.User.Identity.IsAuthenticated)
|
||||||
{
|
{
|
||||||
|
|
@ -8,7 +10,7 @@
|
||||||
|
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li>
|
<li>
|
||||||
@Html.ActionLink("Hello " + Context.HttpContext.User.Identity.Name + "!", "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Manage" })
|
@Html.ActionLink("Hello " + Context.HttpContext.User.Identity.GetUserName() + "!", "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Manage" })
|
||||||
</li>
|
</li>
|
||||||
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
|
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue