/// <summary> /// When a new Transaction is generated in the Process /// </summary> /// <param name="costPerLiterInCent">the cost of the fueltype per liter</param> /// <param name="amount"></param> /// <param name="fueltype"></param> /// <param name="zapfsaulenName"></param> public Transaction(int costPerLiterInCent, int amount, FuelType fueltype, string zapfsaulenName) // SUPER IMPORTANT!: DO NOT USE FUELTYPE FOR COST CALCULATION DO NOT REMOVE COSTPERLITERINCENT { SetDateTimeStampNow(); this.CostPerLiterInCent = costPerLiterInCent; this.Amount = amount; this.FuelTypeName = fueltype.GetFuelTypeName(); this.ZapfsauleName = zapfsaulenName; this.IsPaid = false; }
/// <summary> /// Starts the Tanking Process and calls upon a Callback Method to Update the GUI /// </summary> /// <param name="currentFuelTank">the current selected fueltank</param> /// <param name="callback">the callback to update the gui</param> public void StartTankingTimer(FuelTank currentFuelTank, Action SaveFuelTanks) { this.currentFuelTransactionAmountOfLiter = 0; this.currentFuelTransactionFuelType = currentFuelTank.GetFuelType(); this.tankingState = true; this.tankingTimer = new DispatcherTimer(); this.tankingTimer.Tick += (s, e) => { this.currentFuelTransactionAmountOfLiter += currentFuelTank.DrainFuel(1); SaveFuelTanks(); }; this.tankingTimer.Interval = TimeSpan.FromSeconds(1); this.tankingTimer.Start(); }
/// <summary> /// calculates todays total liters from a certain fueltype /// </summary> /// <param name="fuelType">The fuel type from which the amount of liters needs to be calculated</param> /// <returns>Amount of drained liters from tank according to the fuel type</returns> public int GetTodaysLiterStats(FuelType fuelType) { int totalLiters = 0; // gets fuel amount of paid transactions foreach (Transaction transaction in this.tankstellenkasse.GetPaidTransactions()) { if (transaction.GetDateTime().ToShortDateString() == DateTime.Now.ToShortDateString() && transaction.GetFuelTypeName() == fuelType.GetFuelTypeName()) { totalLiters += transaction.GetTotalFuelAmount(); } } // gets fuel amount of unpaid transactions foreach (Transaction transaction in this.tankstellenkasse.GetUnpaidTransactions()) { if (transaction.GetDateTime().ToShortDateString() == DateTime.Now.ToShortDateString() && transaction.GetFuelTypeName() == fuelType.GetFuelTypeName()) { totalLiters += transaction.GetTotalFuelAmount(); } } return(totalLiters); }
/// <summary> /// constructor for creation of fuelTanks when not exisiting yet /// </summary> /// <param name="fuelType">the Fueltype for which to create the tank for</param> /// <param name="fuelCapacity">the size of the tank in liters</param> public FuelTank(FuelType fuelType, int fuelCapacity) { this.FuelType = fuelType; this.FuelCapacity = fuelCapacity; this.CurrentFuelAmount = 1000; }
/// <summary> /// gets the corresponding FuelTank with the Fueltype provided /// </summary> /// <param name="fueltype">the fueltype which is requested</param> public void GetFuelOfType(FuelType fueltype) { Zapfhahn zapfhahn = zapfhaehne.Find(x => fueltype == x.GetFuelType()); }