public async Task CallPrice(PlaceBidDto input) { long UserId = AbpSession.UserId.Value; User User = await _userManager.FindByIdAsync(UserId.ToString()); DateTime timeStamp = DateTime.UtcNow; string auctionName = $"auction-{input.AuctionId}"; try { Domain.Auction.Auction newValue = await _auctionManager.MakeBid(input.AuctionId, input.Price, UserId, timeStamp); await Clients.Group(auctionName).SendAsync(AuctionHubEventNames.NewBidIsValid, new NewBidDto { BidTime = timeStamp, Price = input.Price, Username = User.UserName, AuctionId = input.AuctionId }); await Clients.User(UserId.ToString()).SendAsync(AuctionHubEventNames.BidSuccess); } catch (Exception e) { await Clients.User(UserId.ToString()).SendAsync(AuctionHubEventNames.BidFail, e.Message); } }
public async Task <AuctionDto> Get(EntityDto input) { Domain.Auction.Auction item = await _auctionManager.GetDetail(input.Id); var result = new AuctionDto { Id = item.Id, EndDate = item.EndDate, InitPrice = item.InitPrice, MinAcceptPrice = item.MinAcceptPrice, ProductId = item.ProductId, StartDate = item.StartDate, CurrentPrice = item.CurrentPrice, NumberOfBids = item.NumberOfBid, UserName = item.Winner?.UserName, SellerId = item.SellerId }; if (item.LastBidTime.Year < 1900) { result.LastBidTime = null; } else { result.LastBidTime = item.LastBidTime; } return(result); }