internal void DeleteAuctionData(string email) { ABUser user = _abUserRepository.FindBy(x => x.Email == email).FirstOrDefault(); Auction auction = user.Auction; if (auction != null) { if (auction.CurrentBid.Bidder.Email == email) { auction.Auction_BidGUID = null; var bidList = _bidRepository.FindBy(x => x.Bid_AuctionGUID == auction.AuctionGUID).ToList(); if (bidList != null && bidList.Count > 0) { foreach (var item in bidList) { _bidRepository.Delete(item); } } _unitOfWork.Commit(); var userList = _abUserRepository.FindBy(x => x.ABUser_AuctionGUID == auction.AuctionGUID).ToList(); if (userList != null && userList.Count > 0) { foreach (var item in userList) { _abUserRepository.Delete(item); } } _unitOfWork.Commit(); _auctionRepository.Delete(auction); _unitOfWork.Commit(); } } }
internal AuctionItemViewModel ViewSellerAuction(string sellerEmail) { AuctionModel postedAuctionModel = new AuctionModel(); BidModel bidInfoModel = new BidModel(); ABUserModel bidderInfoModel = new ABUserModel(); var sellerInfoObj = _abUserRepository.FindBy(x => x.Email == sellerEmail).FirstOrDefault(); var postedAuctionObj = _auctionRepository.FindBy(x => x.AuctionGUID == sellerInfoObj.ABUser_AuctionGUID).FirstOrDefault(); var bidInfoObj = _bidRepository.FindBy(x => x.Bid_AuctionGUID == postedAuctionObj.AuctionGUID).FirstOrDefault(); try { var auctionBidderObj = _abUserRepository.FindBy(x => x.ABUserGUID == bidInfoObj.Bid_ABUserGUID && x.ABUser_AuctionGUID == bidInfoObj.Bid_AuctionGUID).FirstOrDefault(); bidderInfoModel.Alias = auctionBidderObj.Alias; bidInfoModel.BidPlaced = bidInfoObj.BidPlaced; } catch { bidderInfoModel.Alias = "No Bidders"; bidInfoModel.BidPlaced = -1; } postedAuctionModel.AuctionGUID = postedAuctionObj.AuctionGUID; postedAuctionModel.ItemName = postedAuctionObj.ItemName; postedAuctionModel.StartingBid = postedAuctionObj.StartingBid; postedAuctionModel.StartDate = postedAuctionObj.StartDate; postedAuctionModel.EndDate = postedAuctionObj.EndDate; postedAuctionModel.AuctionOver = postedAuctionObj.AuctionOver; postedAuctionModel.SellerSent = postedAuctionObj.SellerSent; postedAuctionModel.BuyerReceived = postedAuctionObj.BuyerReceived; if (postedAuctionObj != null) { if (bidInfoModel != null) { return(new AuctionItemViewModel() { auctionItem = postedAuctionModel, bidderInfo = bidderInfoModel, bidInfo = bidInfoModel }); } else { return(new AuctionItemViewModel() { auctionItem = postedAuctionModel }); } } return(null); }