//Updates the balance of the private person private void UpdateBalance(Object obj, Auction.PriceArgs e) { if(e.Salesman.Person != null && this == e.Salesman.Person) { Balance += AuctionHouse.AuctionFee(e.Price); } else if (e.Buyer.Person != null && this == e.Buyer.Person) { Balance -= e.Price; } }
//Updates the balance of the company private void UpdateBalance(Object obj, Auction.PriceArgs e) { decimal tempBalance = e.Price; if (e.Salesman.Company != null && this == e.Salesman.Company) { Balance += AuctionHouse.AuctionFee(e.Price); } else if (e.Buyer.Company != null && this == e.Buyer.Company) { if (tempBalance > Balance) { tempBalance -= Balance; Balance = 0.0M; Credit -= tempBalance; } } }
//Subscribes the company to the event that updates the balance public void SubscribeToEvent(Auction auction) { auction.UpdateBalanceEvent += UpdateBalance; }
//Removes the company from the event that updates the balance public void RemoveFromEvent(Auction auction) { auction.UpdateBalanceEvent -= UpdateBalance; }
//Method that overloads the previous method to make a different notify method public int PutUpForSale(Vehicle vehicle, Seller salesman, decimal minPrice, NotifyDelegate notify) { if (!AuctionList.Any(x => x.Vehicle.Equals(vehicle))) { ++_auctionNumber; Auction au = new Auction(vehicle, salesman, _auctionNumber, minPrice, notify); AuctionList.Add(au); return _auctionNumber; } else { Console.WriteLine("The vehicle has already been put up for sale!"); return AuctionList.Find(x => x.Vehicle.Equals(vehicle)).AuctionNumber; } }