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