public (bool isWinner, PrizeDto prize, InstantWinMomentDto instantWin) WinCheck() { PrizeDto prizeDto = null; InstantWinMomentDto momentDto = null; var isWinner = false; lock (_instantWinLock) { var winMoment = _instantWinManager.CheckAvailableWinningMoment(); isWinner = winMoment != null; if (isWinner) { _prizeManager.UpdateRemainingNumber(winMoment.Id, out prizeDto); _instantWinManager.MarkAsWon(winMoment); momentDto = winMoment; } } return(isWinner, prizeDto, momentDto); }
public async Task <(bool status, int generatedNumber)> GenerateInstantWinMoments(GeneratorConfig config, List <Allocable> allocables) { var instantList = await _instantWinProvider.GenerateWinningMoments(config); var allocatedPrizes = await _instantWinProvider.AllocatePrizes(allocables, instantList.Count); var counter = 0; for (int index = 0; index < allocatedPrizes.Count; index++) { var instantWin = new InstantWinMomentDto { Id = Guid.NewGuid(), PrizeId = allocatedPrizes[index].Id, IsWon = false, CreatedOn = DateTime.UtcNow, ActivationDate = instantList[index] }; _instantWinManager.Create(instantWin); counter++; } return(counter == allocatedPrizes.Count, counter); }