Beispiel #1
0
        public async Task <GetOfferResponse> Handle(GetOfferRequest request, CancellationToken cancellationToken)
        {
            var offer = await offerService.GetOffer(request.OfferId);

            return(offer != null ? new GetOfferResponse {
                Offer = mapper.Map <OfferDto>(offer)
            }
                : throw new EntityNotFoundException("Offer not found"));
        }
        public async Task <IActionResult> OnGetAsync(string id)
        {
            var offer = await offerService.GetOffer(id);

            if (offer == null)
            {
                return(RedirectToPage("/Index"));
            }

            Offer          = mapper.Map <OfferDto>(offer);
            OfferCardModel = mapper.Map <OfferListDto>(offer);
            OfferDetails   = mapper.Map <OfferDetailsDto>(offer.OfferDetails);

            return(Page());
        }
Beispiel #3
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");
        }