From e013a6e4bff26aa5ab611dba8c26131e3773eac7 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 7 May 2017 10:13:26 -0400 Subject: [PATCH] fix join and leave group --- Project-Unite/Controllers/GroupsController.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Project-Unite/Controllers/GroupsController.cs b/Project-Unite/Controllers/GroupsController.cs index d171d98..55b23b6 100644 --- a/Project-Unite/Controllers/GroupsController.cs +++ b/Project-Unite/Controllers/GroupsController.cs @@ -86,7 +86,8 @@ public ActionResult CreateGroup(GroupViewModel model) public ActionResult JoinGroup(string id) { var db = new ApplicationDbContext(); - var user = db.Users.FirstOrDefault(x => x.Id == User.Identity.GetUserId()); + string UserId = User.Identity.GetUserId(); + var user = db.Users.FirstOrDefault(x => x.Id == UserId); var group = db.Groups.FirstOrDefault(x => x.Id == id); if (group == null) return new HttpStatusCodeResult(404); @@ -99,7 +100,8 @@ public ActionResult JoinGroup(string id) public ActionResult LeaveGroup() { var db = new ApplicationDbContext(); - var user = db.Users.FirstOrDefault(x => x.Id == User.Identity.GetUserId()); + string UserId = User.Identity.GetUserId(); + var user = db.Users.FirstOrDefault(x => x.Id == UserId); var group = db.Groups.FirstOrDefault(x => x.Id == user.GroupId); if (group == null) return new HttpStatusCodeResult(404);