public async Task UpdateMarina() { var response = await _graphQLService .FetchValuesAsync <MarinasResponse>(Queries.Marinas) .ConfigureAwait(false); foreach (var marina in response.Ports.OrderBy(_ => _.Name)) { marina.WaterPk = marina.Water.Pk; var tmp = await _repositoryWrapper.Marinas.GetByUuidAsync(marina.Pk); if (tmp == null) { await _repositoryWrapper.Marinas.InsertAsync(marina); } else if (tmp.Updated != marina.Updated) { marina.Id = tmp.Id; await _repositoryWrapper.Marinas.UpdateAsync(tmp.Id, marina); } } var eventArgs = new DataUpdateEventArgs <Marina> { Type = "marina", Data = await _repositoryWrapper.Marinas.GetAllAsync() }; _eventAggregator .GetEvent <UpdateReadyEvent <Marina> >() .Publish(eventArgs); }