private async void UpdateDatabase() { List <User> userApi = await _apiUserWorker.GetAsync(); List <Payment> paymentApi = await _apiPaymentWorker.GetAsync(); List <User> userDatabase = await _databaseUserWorker.GetAsync(); List <Payment> paymentDatabase = await _databasePaymentWorker.GetAsync(); foreach (User user in userApi) { User search = userDatabase.FirstOrDefault(el => el.Token == user.Token); if (search == null) { await _databaseUserWorker.PostAsync(user); continue; } await _databaseUserWorker.PutAsync(search.Id, user); } foreach (Payment user in paymentApi) { Payment search = paymentDatabase.FirstOrDefault(el => el.Token == user.Token); if (search == null) { await _databasePaymentWorker.PostAsync(user); } } }
public async Task <bool> Post(User value) { User user = await _apiWorker.PostAsync(value); if (user == null) { return(false); } bool result = await _databaseWorker.PostAsync(user); return(result); }
public async Task <bool> Post(Payment value) { Payment payment = await _apiWorker.PostAsync(value); if (payment == null) { return(false); } bool result = await _databaseWorker.PostAsync(payment); return(result); }