This commit is contained in:
masoodafar-web
2025-11-25 05:46:46 +03:30
parent 7ba48b2f11
commit e2bd966098

View File

@@ -14,29 +14,29 @@ public class
public async Task<GetAllUserWalletByFilterResponseDto> Handle(GetAllUserWalletByFilterQuery request,
CancellationToken cancellationToken)
{
#region Remove This Region After Implementing Migration
// This Region Is For Adding UserWallet For Existing Users In Database
var usersWithNoWallet = _context.Users
.Where(u => !_context.UserWallets.Any(uw => uw.UserId == u.Id))
.Select(u => u.Id)
.ToList();
foreach (var userId in usersWithNoWallet)
{
await _context.UserWallets.AddAsync(new UserWallet()
{
UserId = userId,
Balance = 0,
NetworkBalance = 0
}, cancellationToken);
}
if (usersWithNoWallet.Any())
{
await _context.SaveChangesAsync(cancellationToken);
}
#endregion
// #region Remove This Region After Implementing Migration
//
// // This Region Is For Adding UserWallet For Existing Users In Database
// var usersWithNoWallet = _context.Users
// .Where(u => !_context.UserWallets.Any(uw => uw.UserId == u.Id))
// .Select(u => u.Id)
// .ToList();
// foreach (var userId in usersWithNoWallet)
// {
// await _context.UserWallets.AddAsync(new UserWallet()
// {
// UserId = userId,
// Balance = 0,
// NetworkBalance = 0
// }, cancellationToken);
// }
//
// if (usersWithNoWallet.Any())
// {
// await _context.SaveChangesAsync(cancellationToken);
// }
//
// #endregion
var query = _context.UserWallets