private void UpdateDatabaseAsync(IEnumerable <LocalizedItem> items) { CultureInfo culture = Settings.DatabaseCulture; Observable.Start(() => { // select items to update and convert them var dbItems = items .Where(o => o.DatabaseEntity != null && string.IsNullOrEmpty(o.DatabaseEntity.Name) == false && o.TranslatedEntity != null && string.IsNullOrEmpty(o.TranslatedEntity.Name) == false) .Select(GetTranslatedDbItem); if (dbItems.Any() == false) { return; } using (var provider = new MangosProvider()) { dbItems = provider.UpdateItems(dbItems, culture) .ToList(); } // refresh updated items items.Join(dbItems, o => o.DatabaseEntity.Id, o => o.Id, (li, dbi) => new { li, dbi }) .ToList() .ForEach(o => { o.li.Error = null; o.li.DatabaseEntity = o.dbi; }); }); }
private void UpdateDatabaseAsync(IEnumerable <LocalizedItem> items) { CultureInfo culture = Settings.DatabaseCulture; Observable.Start(() => { // select items to update and convert them var dbItems = items //.Where(o => o.Status == LocalizationStatus.NotEqual) .Select(GetTranslatedDbItem); if (dbItems.Any() == false) { return; } using (var provider = new MangosProvider()) { dbItems = provider.UpdateItems(dbItems, culture) .ToList(); } // refresh updated items items.Join(dbItems, o => o.DatabaseEntity.Id, o => o.Id, (li, dbi) => new { li, dbi }) .ToList() .ForEach(o => o.li.DatabaseEntity = o.dbi); }); }