public MainViewModel(IBillCalculator billCalculator, Task<IUserRepository> userRepositoryTask, IFuelPriceAccesser fuelPriceAccesser, ITaksariDialogService messageBoxes) { //Register messengers IMvxMessenger messenger = Mvx.Resolve<IMvxMessenger>(); messenger.Subscribe<ToggleUserActivityMessage>(OnToggleUserActivityMessageReceived, MvxReference.Strong); messenger.Subscribe<DeleteUserMessage>(OnDeleteUserMessageReceived, MvxReference.Strong); messenger.Subscribe<PaymentRequestedMessage>(OnPaymentRequestedMessageReceived, MvxReference.Strong); //FuelPriceAccesser. PropertyChangedEvent is handled for setting new fuelprices to _appsettings AppSettings.FuelPricesAreUpToDate = false; fuelPriceAccesser.FuelPricesUpdated += OnFuelPricesUpdated; //UserRepository _userRepositoryTask = userRepositoryTask; //Init SortingObservableCollections ActiveUserViewModelsTask = new NotifyTaskCompletion<ObservableCollection<IUserViewModel>>(InitActiveUserViewModelsAsync()); ActiveUserViewModelsTask.PropertyChanged += OnActiveUsersTaskPropertyChanged; InActiveUserViewModelsTask = new NotifyTaskCompletion<ObservableCollection<IUserViewModel>>(InitInActiveUserViewModelsAsync()); //BillCalculator _billCalculator = billCalculator; _billCalculator.CostsPerKm = AppSettings.FinalCostsPerKm; _billCalculator.BillsChanged += OnBillsChanged; _billCalculator.LocatorStatusChanged += OnLocatorStatusChanged; //Message boxes _dialogService = messageBoxes; //Default LocatorStatus LocatorStatus = new BindablePositionStatus(WrappedPositionStatus.Ready); }
private void AddBill(DateTime date, BillType billType, params Reading[] readings) { IBillCalculator calculator = BillCalculatorFactory.GetBillCalculator(billType, this); Bill bill = new Bill { Date = date, BillType = billType, Readings = readings, }; bill.Amount = calculator.CalculateBill(bill); _db.Bills.Add(bill); _db.SaveChanges(); }
//Normal constructor which is called //automatically and there is no need to use it //while constructing new item public BillViewModel(IBillCalculator calculator) { _calculation = calculator; }
/// <summary> /// Use constructor injection to supply _calculation with the implementation. /// </summary> /// <param name="calculation"></param> public BillViewModel(IMvxMessenger messenger, IBillCalculator calculation) : base(messenger) { _calculation = calculation; }
public Biller(IBillCalculator billCalculator) { this.billCalculator = billCalculator; }
public BillViewModel(IBillCalculator calculationService) { this._calculationService = calculationService; }