예제 #1
0
        private void LoadCards(List <Lot> lots)
        {
            lotStackPanel.Children.Clear();

            lots.ForEach(lot =>
            {
                var user    = lot.Product.Owner;
                var content = lot.Product.ProductContents.FirstOrDefault() ?? new ProductContent {
                    Content = "../Resources/tree1.png"
                };

                var card = new LotCard
                {
                    Title       = lot.Title,
                    LotId       = lot.Id,
                    Height      = 136,
                    Description = $"{lot.StartBid.ToString()} by {user.Login}",
                    StratBid    = lot.StartBid,
                    ImageSource = new BitmapImage(new Uri(content.Content, UriKind.Relative))
                };

                card.OnDataUpdated       += CardOnOnDataUpdated;       //обновить список лотов
                card.OnDataRequestUpdate += CardOnOnDataRequestUpdate; //заполнить форму на window

                lotStackPanel.Children.Add(card);
            });
        }
예제 #2
0
        public void Refresh(Expression <Func <LotEntity, bool> > predicate = null, string filterMessage = null)
        {
            if (predicate == null)
            {
                predicate = l => l.IsActive;
            }

            FilterTextBlock.Text = filterMessage;

            lotStackPanel.Children.Clear();

            using (var uow = new AuctionUnitOfWork())
            {
                var lots = uow.LotRepository.Select()
                           .Where(predicate)
                           .OrderByDescending(l => l.DateCreated).ToList();

                lots.ForEach(lot =>
                {
                    var card = new LotCard
                    {
                        Title       = lot.Title,
                        LotId       = lot.Id,
                        Height      = 136,
                        Description = String.Format("Стартовая цена: {0:0.00} BYN", lot.StartBid)
                    };
                    var content = lot.LotContents.FirstOrDefault();

                    if (content == null)
                    {
                        card.ImageSource = new BitmapImage(new Uri("../Images/empty_auction.jpg", UriKind.Relative));
                    }
                    else
                    {
                        card.ImageSource = ToImage(content.Content);
                    }

                    card.MouseDown += CardOnMouseDown;
                    lotStackPanel.Children.Add(card);
                });
            }
        }