From 0cdba811a67c0fa8f9a68c8efa9280ea0cf22801 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 3 May 2017 09:08:57 -0400 Subject: [PATCH] query other users' display names --- Project-Unite/Controllers/APIController.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Project-Unite/Controllers/APIController.cs b/Project-Unite/Controllers/APIController.cs index 1c96422..f225c68 100644 --- a/Project-Unite/Controllers/APIController.cs +++ b/Project-Unite/Controllers/APIController.cs @@ -213,7 +213,7 @@ namespace Project_Unite.Controllers } - public ActionResult GetDisplayName() + public ActionResult GetDisplayName(string id = "") { try { @@ -221,7 +221,14 @@ namespace Project_Unite.Controllers var user = ACL.GetUserFromToken(token); if (user == null) return new HttpStatusCodeResult(HttpStatusCode.Forbidden); - return Content(user.DisplayName); + if(string.IsNullOrWhiteSpace(id)) + return Content(user.DisplayName); + + var db = new ApplicationDbContext(); + var uwithid = db.Users.FirstOrDefault(x => x.Id == id); + if (uwithid == null) + return new HttpStatusCodeResult(404); + return Content(uwithid.DisplayName); } catch {