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:
Praburaj 2014-04-16 17:22:05 -07:00
parent 506b439f2f
commit aa7fe89c81
2 changed files with 6 additions and 4 deletions

View File

@ -46,7 +46,7 @@ namespace MusicStore.Controllers
: 1;
order.OrderId = nextId;
order.Username = this.Context.User.Identity.Name;
order.Username = this.Context.User.Identity.GetUserName();
order.OrderDate = DateTime.Now;
//Add the Order
@ -78,7 +78,7 @@ namespace MusicStore.Controllers
// Validate customer owns this order
bool isValid = db.Orders.Any(
o => o.OrderId == id &&
o.Username == this.Context.User.Identity.Name);
o.Username == this.Context.User.Identity.GetUserName());
if (isValid)
{

View File

@ -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)
{
@ -8,7 +10,7 @@
<ul class="nav navbar-nav navbar-right">
<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><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
</ul>