public static MembershipTeam GetCurrentTeam() { var context = HttpContext.Current; var teamName = context.Request.Cookies.Get(TeamCookieName); if (teamName == null || string.IsNullOrEmpty(teamName.Value)) { throw new Exception("Current team does not exist"); } var db = SdcDbContext.Create(); var team = db.Teams.SingleOrDefault(x => x.Name == teamName.Value); if (team == null) { return(null); } return(new MembershipTeam(team)); }