public ViewModelLocator() { ConfigurationBuilder config = new ConfigurationBuilder(); config.AddJsonFile("autofac.json"); ConfigurationModule module = new ConfigurationModule(config.Build()); ContainerBuilder builder = new ContainerBuilder(); builder.RegisterModule(module); Container = builder.Build(); navigationService = Container.Resolve <INavigationService>(); addTripViewModel = Container.Resolve <AddEditTripViewModel>(); addTicketViewModel = Container.Resolve <AddTicketViewModel>(); cityViewModel = Container.Resolve <CityViewModel>(); mainWindowViewModel = Container.Resolve <MainWindowViewModel>(); menuViewModel = Container.Resolve <MenuViewModel>(); routeMapViewModel = Container.Resolve <RouteMapViewModel>(); showTicketViewModel = Container.Resolve <ShowTicketViewModel>(); tripListViewModel = Container.Resolve <TripListViewModel>(); ticketsViewModel = Container.Resolve <TicketListViewModel>(); navigationService.Register <AddEditTripViewModel>(addTripViewModel); navigationService.Register <AddTicketViewModel>(addTicketViewModel); navigationService.Register <CityViewModel>(cityViewModel); navigationService.Register <MenuViewModel>(menuViewModel); navigationService.Register <RouteMapViewModel>(routeMapViewModel); navigationService.Register <ShowTicketViewModel>(showTicketViewModel); navigationService.Register <TicketListViewModel>(ticketsViewModel); navigationService.Register <TripListViewModel>(tripListViewModel); navigationService.Navigate <TripListViewModel>(); }
public FindTripPage() { _network = App.Container.Resolve <INetwork>(); InitializeComponent(); _viewModel = new TripListViewModel(); BindingContext = _viewModel; }
/// <summary> /// Sets up the view model. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="Common.NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { defaultViewModel = (TripListViewModel)this.DataContext; DefaultViewModel.SelectedTrip = null; Window.Current.CoreWindow.VisibilityChanged += CoreWindow_VisibilityChanged; }
public async Task <IViewComponentResult> InvokeAsync(string username, int page) { var allUserTrips = this.tripsService.GetUserTripsWithUsername <TripDetailsViewModel>(username); TripListViewModel model = new TripListViewModel { Trips = allUserTrips, }; return(this.View(model)); }
public IActionResult Index(int?page) { var pageNumber = page ?? 1; this.ViewData["Destinations"] = SelectListGenerator.GetAllDestinations(this.destinationsService); var trips = this.tripsService.GetTripPosts <TripDetailsViewModel>(); var viewModel = new TripListViewModel() { Trips = trips.ToPagedList(pageNumber, GlobalConstants.ItemsPerPage), SearchQuery = new TripSearchInputModel(), }; return(this.View(viewModel)); }
public IActionResult All(int id = 1) { if (id <= 0) { return(this.NotFound()); } const int itemsPerPage = 9; var viewModel = new TripListViewModel { ItemsPerPage = itemsPerPage, PageNumber = id, ItemsCount = this.tripService.GetAllCount(), Trips = this.tripService.GetAllForPaging(id, itemsPerPage), }; return(this.View(viewModel)); }
public IActionResult OrderBy(string order, int id = 1) { if (id <= 0) { return(this.NotFound()); } const int itemsPerPage = 9; var viewModel = new TripListViewModel { ItemsPerPage = itemsPerPage, PageNumber = id, ItemsCount = this.tripService.GetAllCount(), }; switch (order) { case "CreatedOnDesc": viewModel.Trips = this.tripService.OrderAllByCreatedOnDesc(id, itemsPerPage); break; case "CreatedOnAsc": viewModel.Trips = this.tripService.OrderAllByCreatedOnAsc(id, itemsPerPage); break; case "TripDateDesc": viewModel.Trips = this.tripService.OrderAllByTripDateDesc(id, itemsPerPage); break; case "TripDateAsc": viewModel.Trips = this.tripService.OrderAllByTripDateAsc(id, itemsPerPage); break; default: return(this.NotFound()); } return(this.View(viewModel)); }
public TripListView() { InitializeComponent(); BindingContext = new TripListViewModel(this.Navigation); }