Example #1
0
        public static List <string> GetMaxBidsPerUser(string id, CommentsContext context)
        {
            List <BidsModel> bids = context.Bids.Where(x => x.UserId == id).ToList();
            var maxBids           = from e in bids
                                    group e by e.UserId into Auct
                                    let top = Auct.Max(x => x.Value)
                                              select new BidsModel
            {
                UserId    = Auct.Key,
                AuctionId = Auct.First(y => y.Value == top).AuctionId,
                Value     = top,
                Id        = Auct.First(y => y.Value == top).Id,
            };

            return(maxBids.Select(t => t.AuctionId).ToList());
        }
Example #2
0
        private List <string> ReturnIdOfHighestBidOfAuction(string id)
        {
            List <Bids> bd      = bids.Where(x => x.UserId == id).ToList();
            var         maxBids = from e in bd
                                  group e by e.UserId into Auct
                                  let top = Auct.Max(x => x.Value)
                                            select new Bids
            {
                UserId    = Auct.Key,
                AuctionId = Auct.First(y => y.Value == top).AuctionId,
                Value     = top,
                Id        = Auct.First(y => y.Value == top).Id,
            };

            return(maxBids.Select(t => t.AuctionId).ToList());
        }