public async Task <string> Delete() { var customers = kenticoSiteProvider.GetSites(); var now = GetCurrentTime(); var tasks = new List <Task <BaseResponseDto <object> > >(); foreach (var customer in customers) { var config = configurationProvider.Get <MailingListConfiguration>(customer.Name); if (config.DeleteMailingListsPeriod != null) { var deleteOlderThan = now.AddDays(-config.DeleteMailingListsPeriod.Value); tasks.Add(new MailingListClient(new StaticMicroProperties(customer.Name)).RemoveMailingList(deleteOlderThan)); } } var results = await Task.WhenAll(tasks).ConfigureAwait(false); if (results.Any(r => !r.Success)) { return(CreateErrorMessageFromResponses(results, customers)); } return("Done"); }
public async Task <string> UpdateInventoryData() { var sites = kenticoSite.GetSites(); var tasks = new List <Task <string> >(); foreach (var site in sites) { var configuration = configurationProvider.Get <UpdateInventoryConfiguration>(site.Name); var erpId = configuration.ErpClientId; var task = UpdateSiteProducts(erpId); tasks.Add(task); } await Task.WhenAll(tasks.ToArray()).ConfigureAwait(false); return(string.Join(". ", tasks.Select(t => t.Result))); }