fix join and leave group

This commit is contained in:
Michael 2017-05-07 10:13:26 -04:00
parent 5785c29e95
commit e013a6e4bf

View file

@ -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);