Example #1
0
 public AuctionAllBids GetAuctionWithAllBids(Guid id)
 {
     return(Auctions.Where(a => a.id == id)
            .Select(a => new AuctionAllBids
     {
         Auction = new PartialAuction
         {
             id = a.id,
             name = a.name,
             starting_price = a.starting_price,
             duration = a.duration,
             owner = a.owner,
             description = a.description,
             state = a.state,
             created = a.created,
             opened = a.opened,
             closed = a.closed,
             won = a.won
         },
         Bids = a.Bids.OrderByDescending(b => b.amount).Select(bb => new PartialBid
         {
             bidder = bb.bidder,
             amount = bb.amount,
             firstName = bb.Bidder.first_name,
             lastName = bb.Bidder.last_name,
             created = bb.created
         }).ToList()
     }).SingleOrDefault());
 }
Example #2
0
        public IEnumerable <Aukcje.Models.CommentWithAuction> SelectComments()
        {
            IEnumerable <Aukcje.Models.CommentWithAuction> list = new List <CommentWithAuction>();
            IEnumerable <Aukcje.Auction> Auctions;
            IEnumerable <Aukcje.Comment> Comments;

            using (var ctx = new bazaEntities())
            {
                Auctions = ctx.Auctions.ToList();
                Comments = ctx.Comments.ToList();
            }
            string sellerName = HttpContext.Current.Request.QueryString["UID"] ?? view.UName;

            Auctions = Auctions.Where(p => p.seller.Equals(sellerName) && p.status == "zakonczone");

            list = from p in Auctions
                   join c in Comments
                   on p.commentID equals c.CommentID
                   select new CommentWithAuction()
            {
                aukcja = p, Comment = c, ConsumerName = "asd"
            };

            return(list);
        }
        public IEnumerable <Models.CommentWithAuction> GetClosedAuctions(string UserName)
        {
            IEnumerable <Aukcje.Models.CommentWithAuction> list;
            IEnumerable <Aukcje.Auction> Auctions;
            IEnumerable <Aukcje.Comment> Comments;

            using (var ctx = new bazaEntities())
            {
                Auctions = ctx.Auctions.ToList();
                Comments = ctx.Comments.ToList();
            }
            Auctions = Auctions.Where(p => p.seller.Equals(UserName) && p.status == "zakonczone");

            list = from p in Auctions
                   join c in Comments
                   on p.commentID equals c.CommentID
                   select new Models.CommentWithAuction()
            {
                aukcja = p, Comment = c, ConsumerName = "asd"
            };

            return(list);
        }
Example #4
0
 // Full populate methods for DRY
 public Auction PopulateAuctionSingle(int auctionid)
 {
     return(Auctions.Where(x => x.Id == auctionid).Include(x => x.User).Include(x => x.Bids).ThenInclude(x => x.User).SingleOrDefault());
 }