public UserProfileDetails GetUserProfileDetails(string userId) { using (var scope = _serviceProvider.CreateScope()) { var identityContext = scope.ServiceProvider.GetRequiredService <GameBoardAuctionIdentityContext>(); var user = identityContext.Users.Single(user => user.Id.Equals(userId)); var userAuctions = _auctionRepository.GetAuctionByUserId(userId); var userBets = _auctionBetRepository.GetBetsByUserId(userId); return(new UserProfileDetails { UserEmail = user.UserName, Auctions = userAuctions.Select(auction => AuctionDetails.FormAuctionDetails(auction)), TotalMadeBets = userBets.Count() }); } }
public IEnumerable <AuctionDetails> GetAllAuctions() { var auctions = _auctionRepository.GetAuctions(); return(auctions.Select(auction => AuctionDetails.FormAuctionDetails(auction))); }