public AuctionItemOverviewModel(AuctionItem auctionItem)
        {
            Id = auctionItem.Id;
                        AuctionNumber = auctionItem.AuctionNumber;
                        Date = auctionItem.Date;
                        Title = auctionItem.Title;
                        VenderZipCode = auctionItem.VendorZipCode;
                        VendorCity = auctionItem.VendorCity;
                        MinimumPrice = auctionItem.MinimumPrice;

                        var highestBidding = AuctionItemBiddingRepository.Instance.SelectHighest(auctionItem.Id);
                        if (highestBidding != null)
                        {
                                HighestBidding = highestBidding.Bidding;
                                HighestBiddingDate = highestBidding.Date;
                        }

                        var fileAttachmentAuctionItem = FileAttachmentAuctionItemRepository.Instance.SelectFirstByAuctionItem(auctionItem.Id);
                        var fileAttachmentId = 0;
                        if (fileAttachmentAuctionItem != null)
                        {
                                fileAttachmentId = fileAttachmentAuctionItem.FileAttachmentId;
                        }

                        ImageUrl = string.Format("/FileAttachment/{0}?maxheight=250&maxwidth=250", fileAttachmentId);
        }
        public AuctionItemDetailModel(AuctionItem auctionItem)
        {
            Id = auctionItem.Id;
                        AuctionNumber = auctionItem.AuctionNumber;
                        Title = auctionItem.Title;
                        Description = new MvcHtmlString(auctionItem.Description.Replace(Environment.NewLine, "<br/>"));
                        MinimumPrice = auctionItem.MinimumPrice;
                        Ended = auctionItem.Ended;

                        ImageFileAttachments = new List<int>();
                        foreach (var fileAttachmentAuctionItem in FileAttachmentAuctionItemRepository.Instance.ListByAuctionItem(auctionItem.Id))
                        {
                                ImageFileAttachments.Add(fileAttachmentAuctionItem.FileAttachmentId);
                        }

                        Biddings = new List<AuctionItemBiddingModel>();

                        AuctionItemBiddingRepository.Instance.ListByAuctionItem(auctionItem.Id).ForEach(b => Biddings.Add(new AuctionItemBiddingModel(b)));

                        ImageFileAttachment = 0;
                        if (ImageFileAttachments.Count > 0)
                        {
                                ImageFileAttachment = ImageFileAttachments[0];
                        }
        }
        public AuctionItem ToDalEntity()
        {
            var result = new AuctionItem();

            result.Date = DateTime.Now;
            result.Title = Title;
            result.Description = Description;
            result.MinimumPrice = MinimumPrice;
            result.VendorName = VendorName;
            result.VendorStreet = VendorStreet;
            result.VendorHouseNumber = VendorHouseNumber;
            result.VendorZipCode = VendorZipCode;
            result.VendorCity = VendorCity;
            result.VendorEmail = VendorEmail;
            result.VendorPhoneNumber = VendorPhoneNumber;
            result.VendorMobileNumber = VendorMobileNumber;
            result.UniqueKey = Guid.NewGuid();

            return result;
        }