示例#1
0
    private async void DoWork(object state)
    {
        _logger.LogInformation("Background Service Started: updating alliances.");
        List <Alliance> alliances = await _Db.Alliance.ToListAsync();

        foreach (Alliance alliance in alliances)
        {
            // Skip the non-membership alliance
            if (alliance.Id == 0)
            {
                continue;
            }

            var result = await EsiWrapper.GetAlliance(alliance.Id);

            // Do not update the alliacne name if null/errors are returned.
            if (result != null)
            {
                alliance.Name = result.Name;
            }
        }

        await _Db.SaveChangesAsync();

        _logger.LogInformation("Background Service Completed: alliances updated.");
    }
示例#2
0
        public static void EnsureInDatabase(int id, Data.WaitlistDataContext _Db)
        {
            var alliance = _Db.Alliance.Find(id);

            if (alliance != null)
            {
                return;
            }

            var result = EsiWrapper.GetAlliance(id);

            alliance = new Alliance
            {
                Id   = id,
                Name = result.Result.Name
            };

            _Db.Add(alliance);
            _Db.SaveChanges();

            return;
        }