public ClanCreateResult ClanCreate(ClanCreateRequest request) { int userId; this.TryGetUserId(out userId); Clan newClan = new Clan { Name = request.Name, Tag = request.Tag, Description = request.Description }; _clanRepository.CreateAsync(newClan).Wait(); var leaderMembership = new ClanMembership { ClanId = newClan.ClanId, UserId = userId, Role = 1 }; _clanMembershipRepository.CreateAsync(leaderMembership).Wait(); var leaderBaseData = _userBaseDataRepository.GetByUserIdAsync(userId).Result; return(new ClanCreateResult { Result = new ServiceResult <UserBaseData> { Data = leaderBaseData } }); }
public override ClanState AcceptInvite(ClanMembership membership) { FoundingFathers.Add(membership.BattleTag); if (FoundingFathers.Count >= 7) { return(new FoundedClan(FoundingFathers, ChiefTain)); } return(this); }
public void AddUserToClan(int userId, int clanId) { ClanMembership membership = new ClanMembership { UserId = userId, ClanId = clanId, }; _context.ClanMemberships.Add(membership); _context.SaveChanges(); }
public Task DeleteAsync(ClanMembership clanMembership) { var foundClanMembership = _context.ClanMemberships.Find(clanMembership.UserId, clanMembership.ClanId); if (foundClanMembership != null) { _context.ClanMemberships.Remove(foundClanMembership); } _context.SaveChanges(); return(Task.FromResult(0)); }
public Task UpdateAsync(ClanMembership clanMembership) { var foundClanMembership = _context.ClanMemberships.Find(clanMembership.UserId, clanMembership.ClanId); if (foundClanMembership != null) { foundClanMembership.Role = clanMembership.Role; } _context.SaveChanges(); return(Task.FromResult(0)); }
public Task CreateAsync(ClanMembership clanMembership) { _context.ClanMemberships.Add(new Model.ClanMembership { UserId = clanMembership.UserId, ClanId = clanMembership.ClanId, Role = clanMembership.Role }); _context.SaveChanges(); return(Task.FromResult(0)); }
public override ClanState LeaveClan(ClanMembership clanMemberShip) { FoundingFathers.Remove(clanMemberShip.BattleTag); return(this); }
public abstract ClanState LeaveClan(ClanMembership clanMemberShip);
public abstract ClanState AcceptInvite(ClanMembership membership);
private static void SeedServer(IDependencyScope scope) { var userManager = (IHaloUserManager)scope.GetService(typeof(IHaloUserManager)); var userBaseDataRepository = (IUserBaseDataRepository)scope.GetService(typeof(IUserBaseDataRepository)); var userSubscriptionRepository = (IUserSubscriptionRepository)scope.GetService(typeof(IUserSubscriptionRepository)); var clanRepository = (IClanRepository)scope.GetService(typeof(IClanRepository)); var clanMembershipRepository = (IClanMembershipRepository)scope.GetService(typeof(IClanMembershipRepository)); try { var clan = clanRepository.FindByNamePrefixAsync("Clan1").Result.FirstOrDefault(); if (clan == null) { clan = new Clan { Name = "Clan1", Description = "First clan", Tag = "TAG" }; clanRepository.CreateAsync(clan).Wait(); } HaloUser testUser1 = new HaloUser { UserName = "******" }; HaloUser testUser2 = new HaloUser { UserName = "******" }; userManager.CreateAsync(testUser1, "123").Wait(); userManager.CreateAsync(testUser2, "456").Wait(); UserBaseData testUser1Data = new UserBaseData { User = new UserId { Id = testUser1.UserId }, Nickname = "User1", Clan = new ClanId { Id = 0 }, ClanTag = "", Level = 2, BattleTag = "BattleTag1" }; UserBaseData testUser2Data = new UserBaseData { User = new UserId { Id = testUser2.UserId }, Nickname = "User2", Clan = new ClanId { Id = 0 }, ClanTag = "", Level = 10, BattleTag = "BattleTag2" }; userBaseDataRepository.SetUserBaseDataAsync(testUser1Data); userBaseDataRepository.SetUserBaseDataAsync(testUser2Data); var testUser1ClanMembership = new ClanMembership { UserId = testUser1.UserId, ClanId = clan.ClanId, Role = 1 }; clanMembershipRepository.CreateAsync(testUser1ClanMembership).Wait(); var testUser1Subscription = new UserSubscription { UserId = testUser1.UserId, FriendUserId = testUser2.UserId }; userSubscriptionRepository.CreateAsync(testUser1Subscription).Wait(); } catch (Exception) { Debug.WriteLine("Server initialization failed."); } }
public override ClanState AcceptInvite(ClanMembership membership) { Members.Add(membership.BattleTag); return(this); }