From bf85c3cda26d1ca3603d0a72e1cd3330335a73b1 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 21 Mar 2017 13:07:03 -0400 Subject: [PATCH] Another ACL bug. --- Project-Unite/ACL.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Project-Unite/ACL.cs b/Project-Unite/ACL.cs index aca67a5..df57671 100644 --- a/Project-Unite/ACL.cs +++ b/Project-Unite/ACL.cs @@ -46,9 +46,15 @@ public static IHtmlString UserName(this HtmlHelper hpr, string userId) { userRoles.Add(db.Roles.FirstOrDefault(r => r.Id == usrRole.RoleId) as Role); } - var userRole = userRoles.OrderByDescending(m => m.Priority).First(); - return hpr.Raw($@"{hpr.Encode(usr.DisplayName)}"); - + var userRole = userRoles.OrderByDescending(m => m.Priority).FirstOrDefault(); + if (userRole == null) + { + return hpr.Raw($@"{hpr.Encode(usr.DisplayName)}"); + } + else + { + return hpr.Raw($@"{hpr.Encode(usr.DisplayName)}"); + } } }