public void OnStart() { bool IsEmptyCarList; bool IsEmptyRefuelingList; using (var uof = new UnitOfWork(new FuelContext())) { IsEmptyCarList = uof.CarRepository.IsEmpty(); IsEmptyRefuelingList = uof.RefuelingRepository.IsEmpty(); } if (IsEmptyCarList && IsEmptyRefuelingList) { ViewModelsList.Add(new FirstRunViewModel()); CurrentViewModel = ViewModelsList.FirstOrDefault(x => x.Name == "FirstRun"); } else if (IsEmptyRefuelingList) { ViewModelsList.Add(new CarsViewModel()); ViewModelsList.Add(new RefuelingViewModel()); CurrentViewModel = ViewModelsList.FirstOrDefault(x => x.Name == "Tankowanie"); } else { ViewModelsList.Add(new CarsViewModel()); ViewModelsList.Add(new RefuelingViewModel()); ViewModelsList.Add(new StaticticsViewModel()); ViewModelsList.Add(new DiagramsViewModel()); CurrentViewModel = ViewModelsList.FirstOrDefault(x => x.Name == "Tankowanie"); } }
public void ChangeViewModel(IPageViewModel viewmodel) { if (!ViewModelsList.Contains(viewmodel)) { ViewModelsList.Add(viewmodel); } CurrentViewModel = ViewModelsList.FirstOrDefault(x => x == viewmodel); }