private void UpdateSites() { _logger.Information("Updating Sites"); SiteDal dal = new SiteDal(_configuration, _logger); DateTime?lastUpdate = dal.GetLastAdded(); if (lastUpdate == null || lastUpdate.Value.Year == 0) { InitialiseSites(); } else { IEnumerable <SiteModel> siteModels = new SOAPHelper(_autotaskApiUsername, _autotaskApiPassword, _autotaskApiIntegrationCode, _autotaskApiUrl, _logger) .RetrieveNewSites(lastUpdate.Value); if (siteModels != null && siteModels.Count() > 0) { _logger.Information($"{siteModels.Count()} new Sites found"); } { foreach (SiteModel site in siteModels) { Domain.Enums.CRUDEnums.ActionResult actionResult = dal.Put(site).GetAwaiter().GetResult(); } } } }
private void UpdateTickets() { _logger.Information("Updating Tickets"); TicketDal dal = new TicketDal(_configuration, _logger); DateTime? lastUpdate = dal.GetLastUpdated(); if (lastUpdate == null || lastUpdate.Value.Year == 0) { _logger.Information("No tickets found trying initalisation"); InitialiseTickets(); } else { IEnumerable <TicketModel> ticketModels = new SOAPHelper(_autotaskApiUsername, _autotaskApiPassword, _autotaskApiIntegrationCode, _autotaskApiUrl, _logger) .RetriveUpdatedTickets(lastUpdate.Value); if (ticketModels != null && ticketModels.Count() > 0) { _logger.Information($"{ticketModels.Count()} updated Tickets found"); Domain.Enums.CRUDEnums.ActionResult actionResult = dal.PutOrPost(ticketModels).GetAwaiter().GetResult(); } } }