Hi,
I am trying to update the table. But it does not. How come, I don't understand. There is no error either.
Generic Repo:
Unit of work: :
I am trying to update the table. But it does not. How come, I don't understand. There is no error either.
C#:
...
var gameBankResult =
await _unitOfWork.GameBankRepository.GetGamesAsync(g =>
g.productCode == requestDto.productCode && g.referenceId == Guid.Empty); --> returns 1 result
//If we have exact number of games in our database, mark them!
if (gameBankResult.Count() != 0 && gameBankResult.Count() >= requestDto.quantity)
{
for (var index = 0; index < requestDto.quantity; index++)
{
var item = gameBankResult[index];
item.referenceId = gameRequest.referenceId;
item.requestDateTime = DateTime.Now;
item.responseDateTime = DateTime.Now;
_unitOfWork.GameBankRepository.Update(item);
await _unitOfWork.SaveAsync(); ---> does not update the table
}
//Query GameBank database
var gameBankConfirmResult =
await _unitOfWork.GameBankRepository.GetGamesAsync(g =>
g.referenceId == gameRequest.referenceId); ---> returns no result
...
Generic Repo:
C#:
public virtual void Update(TEntity entityToUpdate)
{
dbSet.Attach(entityToUpdate);
context.Entry(entityToUpdate).State = EntityState.Modified;
}
Unit of work: :
C#:
public async Task SaveAsync()
{
await _context.SaveChangesAsync();
}