public async Task UpdateNewProductsAsync() { var products = await _client.GetNewProductsAsync().ConfigureAwait(false); foreach (var product in products) { await _source.AddAsync(product).ConfigureAwait(false); } }
public async Task DataTestsAdd(string name, decimal price, bool isCorrect) { bool isCompletedSuccessfully = true; try { await source.AddAsync(new Product { Name = name, Price = price }); } catch { isCompletedSuccessfully = false; } Assert.Equal(isCorrect, isCompletedSuccessfully); }
public async Task UpdateProductsAsync(IUser user, IEnumerable <IProduct> products) { var userProfile = await _userSource.FindAsync(phoneNumber : user.Phone); if (userProfile is null) { userProfile = await _userSource.FindAsync(email : user.Email); } if (userProfile is null) { throw new Exception("User not found"); } if (userProfile.UserState != UserState.Admin) { throw new Exception("Forbidden"); } List <Task> tasks = new List <Task>(); foreach (var product in products) { tasks.Add(_productSource.AddAsync(product)); } await Task.WhenAll(tasks); }