public Task Invite(long teamId, string userId)
 {
     var membership = new Membership
     {
         TeamId = teamId,
         AccountId = userId,
         Id = random.Next(),
         Status = MembershipStatus.Invited
     };
     memberships.Add(membership.Id, membership);
     return Task.Delay(0);
 }
 public Task<Team> CreateTeam(Team team, string userId)
 {
     team.Id = random.Next();
     teams.Add(team.Id, team);
     var membership = new Membership
     {
         Id = random.Next(),
         AccountId = userId,
         Status = MembershipStatus.Admin,
         TeamId = team.Id
     };
     memberships.Add(membership.Id, membership);
     return Task.FromResult(team);
 }
 public Task Invite(string fromId, string toId, long teamId)
 {
     var invitation = new Membership
     {
         Id = random.Next(),
         AccountId = toId,
         TeamId = teamId,
         Status = MembershipStatus.Invited
     };
     memberships.Add(invitation.Id, invitation);
     return Task.Delay(0);
 }
 public void JoinTeam(string userId, long teamId)
 {
     var existing = memberships.Values.FirstOrDefault(m => m.AccountId == userId && teamId == m.TeamId);
     if (existing != null && existing.Status != MembershipStatus.Banned)
     {
         existing.Status = MembershipStatus.Member;
         return;
     }
     var membership = new Membership
     {
         Id = random.Next(),
         AccountId = userId,
         TeamId = teamId,
         Status = MembershipStatus.Member
     };
     memberships.Add(membership.Id, membership);
 }