public void SwitchGamingGroupContext(int gamingGroupId, ApplicationUser currentUser)
{
if (gamingGroupId == currentUser.CurrentGamingGroupId)
{
return;
}
bool hasAccess = dataContext.GetQueryable<UserGamingGroup>()
.Any(userGamingGroup => userGamingGroup.ApplicationUserId == currentUser.Id
&& userGamingGroup.GamingGroupId == gamingGroupId);
if (!hasAccess)
{
throw new UnauthorizedAccessException(string.Format(EXCEPTION_MESSAGE_NO_ACCESS, currentUser.Id, gamingGroupId));
}
var user = dataContext.FindById<ApplicationUser>(currentUser.Id);
user.CurrentGamingGroupId = gamingGroupId;
dataContext.Save(user, currentUser);
}
}