예제 #1
0
        protected override DriverResult Display(BidsPart part, string displayType, dynamic shapeHelper)
        {
            return(Combined(
                       ContentShape("Parts_ListOfBids", () => {
                var settings = part.Settings.GetModel <BidsPartSettings>();

                var list = shapeHelper.List();
                var bids = part
                           .Bids
                           .OrderByDescending(b => b.BidPrice)
                           .AsQueryable();

                if (settings.DefaultBidsShown > 0)
                {
                    bids = bids.Take(settings.DefaultBidsShown);
                }

                list.AddRange(bids.ToList().Select(b => _contentManager.BuildDisplay(b)));

                return shapeHelper.Parts_ListOfBids(List: list);
            }),
                       ContentShape("Parts_BidForm", () => {
                var minimumBid = part.MinimumBidPrice;
                var heighestBid = _bidService.GetHeighestBid(part.Id);
                if (heighestBid != null && heighestBid.BidPrice > minimumBid)
                {
                    minimumBid = heighestBid.BidPrice;
                }

                var newBid = _contentManager.New("Bid");
                if (newBid.Has <BidPart>())
                {
                    var bidPart = newBid.As <BidPart>();
                    bidPart.BidedOn = part.Id;
                }

                var editorShape = _contentManager.BuildEditor(newBid);

                return shapeHelper.Parts_BidForm(EditorShape: editorShape, CanStillBid: _bidService.CanStillBidOn(part), MinimumBid: minimumBid);
            })));
        }