Esempio n. 1
0
        public async Task <DenyOfferAuctionResponse> Handle(DenyOfferAuctionRequest request, CancellationToken cancellationToken)
        {
            var offer = await offerService.GetOffer(request.OfferId) ?? throw new EntityNotFoundException("Offer not found");

            var denied = await auctionManager.DenyAuction(request.AuctionId, request.OfferId);

            if (denied)
            {
                var followersIds = FollowersUtils.GetFollowersIds(offer.Owner);

                foreach (var followerId in followersIds)
                {
                    var notification = await notifier.Push(NotificationMessages.OfferAuctionDenied(request.OfferId), followerId);

                    await hubManager.Invoke(SignalrActions.NOTIFICATION_RECEIVED, followerId, mapper.Map <NotificationDto>(notification));
                }

                return(new DenyOfferAuctionResponse());
            }

            throw new CrudException("Deny offer auction failed");
        }