Пример #1
0
            /// <summary>
            /// Add list of Users Currency
            /// </summary>
            /// <param name="UserList">todo: describe UserList parameter on AddCurrencyToUserList</param>
            public async static void AddCurrencyToUserList(List <Models.DatabaseCurrencyModel.ListCurrencyUpdate> UserList)
            {
                using (var context = new Storage.StorageEntities()) {
                    foreach (var user in UserList)
                    {
                        var userDb = context.Users.SingleOrDefault(u => String.Compare(u.Id, user.TwitchID) == 0);

                        if (userDb != null)
                        {
                            userDb.Currency.Value += user.Value;
                        }
                    }

                    await context.SaveChangesAsync();
                }
            }
Пример #2
0
        /// <summary>
        /// Add User to Table Currency
        /// </summary>
        /// <param name="twitchID"></param>
        public async static void AddUserToCurrencyTable(string twitchID)
        {
            using (var context = new Storage.StorageEntities()) {
                var currencyEntry = context.Currency.SingleOrDefault(c => String.Compare(c.ID, twitchID) == 0);

                if (currencyEntry == null)
                {
                    context.Currency.Add(
                        new Storage.Currency {
                        ID    = twitchID,
                        Value = 0
                    });

                    await context.SaveChangesAsync();
                }
            }
        }