public async Task InviteToClan(string battleTag, string clanId, string personWhoInvitesBattleTag) { var clanMemberShip = await _clanRepository.LoadMemberShip(battleTag) ?? ClanMembership.Create(battleTag); var clan = await _clanRepository.LoadClan(clanId); if (clan == null) { throw new ValidationException("Clan not found"); } clan.Invite(clanMemberShip, personWhoInvitesBattleTag); await _clanRepository.UpsertClan(clan); await _clanRepository.UpsertMemberShip(clanMemberShip); }
public async Task <Clan> AcceptInvite(string playerBattleTag, string clanId) { var clan = await _clanRepository.LoadClan(clanId); var clanMemberShip = await _clanRepository.LoadMemberShip(playerBattleTag) ?? ClanMembership.Create(playerBattleTag); clan.AcceptInvite(clanMemberShip); await _clanRepository.UpsertClan(clan); await _clanRepository.UpsertMemberShip(clanMemberShip); return(clan); }
public async Task <Clan> CreateClan(string clanName, string clanAbbrevation, string battleTagOfFounder) { var memberShip = await _clanRepository.LoadMemberShip(battleTagOfFounder) ?? ClanMembership.Create(battleTagOfFounder); var clan = Clan.Create(clanName, clanAbbrevation, memberShip); var wasSaved = await _clanRepository.TryInsertClan(clan); if (!wasSaved) { throw new ValidationException("Clan Name allready taken"); } memberShip.ClanId = clan.ClanId; memberShip.ClanName = clan.ClanName; await _clanRepository.UpsertMemberShip(memberShip); return(clan); }