Exemple #1
0
        public static async Task AddUser(string apiKey)
        {
            using (var db = new UserContextFactory().CreateDbContext()) {
                var user = await GetUser(apiKey);

                if (user == null)
                {
                    var account = await AccountAPI.Account(apiKey);

                    if (db.User.Any(x => x.AccountName.Equals(account.Name)))
                    {
                        var existingUser = db.User.FirstOrDefault(x => x.AccountName.Equals(account.Name));
                        db.Key.Add(new Key {
                            UserID = existingUser.ID, APIKey = apiKey
                        });
                    }
                    else
                    {
                        var addedUser = db.User.Add(new User {
                            AccountName = account.Name
                        });
                        await db.SaveChangesAsync();

                        db.Key.Add(new Key {
                            UserID = addedUser.Entity.ID, APIKey = apiKey
                        });
                    }
                    await db.SaveChangesAsync();
                }
            }
        }
Exemple #2
0
        private async Task <List <API.Model.Items.Item> > GetAccountDyes(string apiKey)
        {
            var dyes = await AccountAPI.Dyes(apiKey);

            var colors = await MiscellaneousAPI.Colors(dyes);

            return(await ItemAPI.Items(colors.Select(x => x.Item).ToList()));
        }
Exemple #3
0
        public void ThenTheUserConfirmTheRegistration()
        {
            Login user = new Login()
            {
                userName = _user.UserName,
                password = _user.Password
            };
            var answer = AccountAPI.registerUser(user);

            answer.StatusCode.ToString().Should().Be("Created");
        }
Exemple #4
0
        public static async Task <AccountInventory> GetAccountInventory(string apiKey)
        {
            var accountInv = new AccountInventory()
            {
                Account         = await AccountAPI.Account(apiKey),
                Characters      = await CharacterAPI.Characters(apiKey),
                Bank            = await AccountAPI.Bank(apiKey),
                SharedInventory = await AccountAPI.SharedInventory(apiKey),
                Materials       = await AccountAPI.MaterialStorage(apiKey),
                Wallet          = await AccountAPI.Wallet(apiKey)
            };
            await accountInv.SetGuildBank(apiKey);

            return(accountInv);
        }
Exemple #5
0
        internal async Task Populate(string apiKey)
        {
            Wallet = await AccountAPI.Wallet(apiKey);

            var characterResult = await CharacterAPI.Characters(apiKey);

            Characters = GroupItems(CharacterItems(characterResult));

            var bankResult = await AccountAPI.Bank(apiKey);

            Bank = GroupItems(GetItems(bankResult.Cast <Equipment>().ToList()));

            var sharedResult = await AccountAPI.SharedInventory(apiKey);

            SharedInventory = GroupItems(GetItems(sharedResult.Cast <Equipment>().ToList()));

            MaterialStorage = GroupItems(GetItems(await AccountAPI.MaterialStorage(apiKey)));
            DeliveryBox     = GroupItems(GetItems(GetDeliveryBox(await CommerceAPI.DeliveryBox(apiKey))));
            GuildBank       = GroupItems(GetItems(await GetGuildInventory(await AccountAPI.Account(apiKey), apiKey)));
        }
Exemple #6
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="client">操作类</param>
 public AccountInterface(Client client)
     : base(client)
 {
     api = new AccountAPI(client);
 }
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="client">操作类</param>
		public AccountInterface(Client client)
			: base(client)
		{
			api = new AccountAPI(client);
		}
 public GetGameSessionInfoRequestContext(AccountAPI parent)
 {
     this.m_parent = parent;
 }
Exemple #9
0
        private async Task <List <API.Model.Miscellaneous.Mini> > GetAccountMinis(string apiKey)
        {
            var miniIDs = await AccountAPI.Minis(apiKey);

            return(await MiscellaneousAPI.Minis(miniIDs));
        }
Exemple #10
0
        private async Task <List <API.Model.Items.Skin> > GetAccountSkins(string apiKey)
        {
            var skinIDs = await AccountAPI.Skins(apiKey);

            return(await ItemAPI.Skins(skinIDs));
        }
Exemple #11
0
 public AccountController(AccountAPI account)
 {
     _account = account;
 }