private void UpdateRecordAmountMultiplesUsers(OweRecord record, ReceiptItem receiptItem) { if (record.Amount < 0) { record.Amount += (receiptItem.Count * receiptItem.Price) / receiptItem.Users.Count; } else { record.Amount -= (receiptItem.Count * receiptItem.Price) / receiptItem.Users.Count; } }
private void AddOweRecordAmount(OweRecord record, ReceiptItem receiptItem) { if (record.Amount < 0) { record.Amount += (receiptItem.Count * receiptItem.Price) / receiptItem.Users.Count; } else { record.Amount -= (receiptItem.Count * receiptItem.Price) / receiptItem.Users.Count; } }
private async Task CreateOweRecordForNewUsers(List <string> newUsers, ICollection <FinancialProjectApplicationUser> currentUsers, CancellationToken cancellationToken) { foreach (var newUser in newUsers) { foreach (var projectApplicationUser in currentUsers) { //create OweRecord var oweRecord = new OweRecord { Id = Guid.NewGuid().ToString(), Amount = 0, FinancialProjectId = _financialProjectId, UserId = newUser, OwedUserId = projectApplicationUser.UserId }; await _context.OweRecords.AddAsync(oweRecord, cancellationToken); } } }
private async Task CreateOweRecord(IEnumerable <ApplicationUser> users, string financialProjectId, string applicationUserId, CancellationToken cancellationToken) { foreach (var user in users) { if (user.Id == applicationUserId) { continue; } //create OweRecord var oweRecord = new OweRecord { Id = Guid.NewGuid().ToString(), Amount = 0, FinancialProjectId = financialProjectId, UserId = applicationUserId, OwedUserId = user.Id }; await _context.OweRecords.AddAsync(oweRecord, cancellationToken); } }
private async Task CreateOweRecordForEachOtherNewUser(List <string> newUsers, CancellationToken cancellationToken) { foreach (var newUser in newUsers) { foreach (var user in newUsers) { if (newUser == user) { continue; } var oweRecord = new OweRecord { Id = Guid.NewGuid().ToString(), Amount = 0, FinancialProjectId = _financialProjectId, UserId = newUser, OwedUserId = user }; await _context.OweRecords.AddAsync(oweRecord, cancellationToken); } } }