public List <AuctionControlData> Search(string searchString) { try { var auctions = (from a in db.Auctions.Where(au => !au.Finalized && au.EndDate > DateTime.Now && au.Title.Contains(searchString)) join u in db.aspnet_Users on a.OwnerId equals u.UserId join t in db.Bidders on a.Id equals t.AuctionId into Bids join s in db.Shipments on a.ShipmentId equals s.Id //join i in db.Images on a.Id equals i.AuctionId select new AuctionControlData() { Title = a.Title, AuctionId = a.Id, //Image = i.ImageData, BuyItNowPrice = a.BuyItNowPrice, BestPrice = Bids.Max(p => p.Price).ToString().Length == 0 ? 0 : Bids.Max(p => p.Price), BestPriceUsername = (from o in db.aspnet_Users where o.UserId == Bids.OrderByDescending(p => p.Price).FirstOrDefault().BidderId select o).FirstOrDefault().UserName,//o.UserName, MinimumPrice = a.MinimumPrice, SellerName = u.UserName, SellerId = a.OwnerId, ShipmentName = s.Name, ShipmentId = a.ShipmentId, ShipmentPrice = s.Price, EndDate = a.EndDate, OffersNum = Bids.Count(), Views = a.Views }).ToList(); return(auctions); } catch (Exception e) { Debug.WriteLine(e.ToString()); } return(new List <AuctionControlData>()); }
public override string ToString() { return($"{Source} - {AssetPair}, Bids: {Bids.Count()}, Asks: {Asks.Count()}, BestBid: {BestBid?.Price}, BestAsk: {BestAsk?.Price}, Timestamp: {Timestamp}"); }