public async Task <bool> Execute(ImportParameter importParameter) { if (importParameter == null) { throw new ArgumentNullException(nameof(importParameter)); } if (importParameter.Clients == null) { throw new ArgumentNullException(nameof(importParameter.Clients)); } _managerEventSource.StartToImport(); // 1. Remove all the clients if (!await _clientRepository.RemoveAllAsync()) { return(false); } _managerEventSource.RemoveAllClients(); // 2. Import the clients foreach (var client in importParameter.Clients) { try { await _clientRepository.InsertAsync(client); } catch (Exception ex) { _managerEventSource.Failure(ex); } } _managerEventSource.FinishToImport(); return(true); }
public Task <bool> Import(ImportParameter importParameter) { return(_importAction.Execute(importParameter)); }