Пример #1
0
        public async Task RemovePrizeAsync(int prizeWinnerId)
        {
            VerifyManagementPermission();

            int authUserId = GetClaimId(ClaimType.UserId);
            var prize      = await _prizeWinnerRepository.GetByIdAsync(prizeWinnerId);

            if (!prize.RedeemedAt.HasValue)
            {
                await _prizeWinnerRepository.RemoveSaveAsync(authUserId, prizeWinnerId);

                if (prize.DrawingId.HasValue)
                {
                    var winnerCount = await _drawingRepository.GetWinnerCountAsync(
                        prize.DrawingId.Value);

                    if (winnerCount == 0)
                    {
                        await _drawingRepository.SetArchivedAsync(authUserId, prize.DrawingId.Value,
                                                                  true);
                    }
                }
            }
            else
            {
                _logger.LogError($"User {authUserId} cannot remove claimed prize {prize.Id}.");
                throw new GraException("Prizes that have been claimed cannot be removed.");
            }
        }
Пример #2
0
        public async Task RemovePrize(int prizeWinnerId)
        {
            VerifyManagementPermission();

            int authUserId = GetClaimId(ClaimType.UserId);
            var prize      = await _prizeWinnerRepository.GetByIdAsync(prizeWinnerId);

            await _prizeWinnerRepository.RemoveSaveAsync(authUserId, prizeWinnerId);
        }