public bool GetHighestUniqueBid() { Bid = null; try { RealEntities db = new RealEntities(); var bids = db.bids.Where(b => b.property_id == PropertyId).GroupBy(b => (b.bid_price.plot_price + b.bid_price.apartment_price)).Where(b => (b.Count() == 1)).FirstOrDefault(); if (null == bids) { return(false); } var bid = bids.FirstOrDefault(); if (null == bid) { return(false); } Bid = new BidVieModel(); Bid.BidId = bid.bid_id; Bid.PropertyId = bid.property_id; Bid.BuyerId = bid.buyer_id; Bid.Status = ( BidStatus )bid.status; Bid.LandPrice = ( double )bid.bid_price.plot_price; Bid.HousePrice = ( double )bid.bid_price.apartment_price; Bid.BuyerName = bid.buyer.user.first_name + " " + bid.buyer.user.last_name; Bid.BuyerAddress = bid.buyer.user.address; return(true); } catch (Exception ex) { } return(false); }
public bool GetBids() { if (null != Bids) { Bids.Clear(); } else { Bids = new List <BidVieModel>(); } try { RealEntities db = new RealEntities(); var bids = db.bids.Where(b => b.property_id == PropertyId); if (null != bids) { foreach (var b in bids) { BidVieModel bid = new BidVieModel(); bid.BidId = b.bid_id; bid.PropertyId = b.property_id; bid.BuyerId = b.buyer_id; bid.Status = ( BidStatus )b.status; //bid.LandPrice = ( double )b.bid_price.plot_price; //bid.HousePrice = ( double )b.bid_price.apartment_price; //bid.BuyerName = b.buyer.user.first_name + " " + b.buyer.user.last_name; //bid.BuyerAddress = b.buyer.user.address; Bids.Add(bid); } } return(true); } catch (Exception ex) { } return(false); }