private void button1_Click(object sender, EventArgs e) { generateMainBody = new GenerateMainBody(); cvERepo.currentNumberOfDocs = cvERepo.MaxNumberOfDocs; var mainBodies = new List <MainBody>(); for (int i = 0; i < 30; i++) { if (!DataFromApi.IsApiOnline()) { break; } var mainbody = new MainBody { Name = generateMainBody.Get() }; if (!mainBodies.Any(m => m.Name == mainbody.Name)) { cvERepo.sendData(new MainBody { Name = generateMainBody.Get() }, Options.Create); mainBodies.Add(mainbody); } } MessageBox.Show("Done!"); }
//private void setMaxNumberOfDocs() //{ // foreach (var domain in Domains) // { // if (domain.Documents.Count > maxNumberOfDocs) // { // maxNumberOfDocs = domain.Documents.Count; // } // } //} public async Task getData() { dataFromApi = new DataFromApi(); Domains = await dataFromApi.getApiDomains(); titles = await dataFromApi.getTitles(); MainBodies = await dataFromApi.getMainBodies(); }
private CvERepo() { if (DataFromApi.IsApiOnline()) { Task.Run(() => instance.getData()); } else { RestoreOfflineData(); } }
public void sendData(IDto _dto, Options options) { if (!DataFromApi.IsApiOnline()) { MessageBox.Show("API offline, unable to send data at the moment"); return; } StoreDataToApi store = new StoreDataToApi(_dto); if (options == Options.Create) { store.CreateData(); } else if (options == Options.Delete) { store.delData(); } Task.Run(() => refreshData()).Wait(); }