Esempio n. 1
0
        public async Task <bool> UpdateSubTiers(Sub[] subs)
        {
            try
            {
                var t1 = subs.Where(s => s.Tier == "1000").ToList();
                var t2 = subs.Where(s => s.Tier == "2000").ToList();
                var t3 = subs.Where(s => s.Tier == "3000").ToList();


                await _dbContext.Database.ExecuteSqlRawAsync("UPDATE [user] SET [subtier] = 0");

                if (t1.Count > 0)
                {
                    await _dbContext.Database.ExecuteSqlRawAsync(BitcornUtils.BuildSubtierUpdateString(t1, 1));
                }
                if (t2.Count > 0)
                {
                    await _dbContext.Database.ExecuteSqlRawAsync(BitcornUtils.BuildSubtierUpdateString(t2, 2));
                }
                if (t3.Count > 0)
                {
                    await _dbContext.Database.ExecuteSqlRawAsync(BitcornUtils.BuildSubtierUpdateString(t3, 3));
                }

                return(true);
            }
            catch (Exception e)
            {
                //_logger.LogError(e, $"Failed to update subtiers {data}");
                return(false);
            }
        }
Esempio n. 2
0
        public async Task <HttpStatusCode> Post([FromBody] Sub[] subs)
        {
            try
            {
                var t1 = subs.Where(s => s.Tier == "1000").ToList();
                var t2 = subs.Where(s => s.Tier == "2000").ToList();
                var t3 = subs.Where(s => s.Tier == "3000").ToList();

                await _dbContext.Database.ExecuteSqlRawAsync("UPDATE [user] SET [subtier] = 0");

                if (t1.Count > 0)
                {
                    await _dbContext.Database.ExecuteSqlRawAsync(BitcornUtils.BuildSubtierUpdateString(t1, 1));
                }
                if (t2.Count > 0)
                {
                    await _dbContext.Database.ExecuteSqlRawAsync(BitcornUtils.BuildSubtierUpdateString(t2, 2));
                }
                if (t3.Count > 0)
                {
                    await _dbContext.Database.ExecuteSqlRawAsync(BitcornUtils.BuildSubtierUpdateString(t3, 3));
                }
                return(HttpStatusCode.OK);
            }
            catch (Exception e)
            {
                //_logger.LogError(e, $"Failed to update subtiers {data}");
                return(HttpStatusCode.InternalServerError);
            }
        }