public IActionResult Create() { LineCreateViewModel model = new LineCreateViewModel() { Trains = trainService.GetAll(), DepartureTime = DateTime.Now.Date, ArrivalTime = DateTime.Now.Date, Date = DateTime.Now.Date }; return(View(model)); }
public void RefreshTrains() { ObservableCollection <TrainDTO> trains = new ObservableCollection <TrainDTO>(); foreach (TrainDTO train in trainService.GetAll().Data.ToList <TrainDTO>()) { if (train.StationId == SelectedStationId) { trains.Add(train); } } Trains = trains; OnPropertyChanged(nameof(Trains)); }
public IActionResult Index() { TrainsIndexViewModel model = new TrainsIndexViewModel() { Trains = trainService.GetAll().Select(t => new TrainIndexViewModel() { Capacity = t.Capacity, IsFast = t.Type == "Fast", Number = t.Number, TrainId = t.Id }).ToList() }; return(View(model)); }
public IActionResult All(int page) { if (page <= 0) { return(Redirect("/Home/Index")); } int reservationsCount = trainService.GetCount(); var lastPage = reservationsCount / GlobalConstants.TrainsPerPage + 1; if (reservationsCount % GlobalConstants.TrainsPerPage == 0 && lastPage > 1) { lastPage--; } if (page > lastPage) { return(Redirect("/Home/Index")); } var trains = trainService.GetAll(page); var viewModel = new ListingPageViewModel { CurrentPage = page, TotalTrainsCount = trains.Count, LastPage = lastPage, Trains = new List <TrainViewModel>() }; foreach (var train in trains) { viewModel.Trains.Add(new TrainViewModel() { Id = train.Id, Name = train.Name, Capacity = train.Capacity, Fast = train.Fast }); } return(View(viewModel)); }
// GET: Platform/Train public ActionResult Index(string keyword, string ordering, int pageIndex = 1) { var model = _trainService.GetAll() .Select( a => new { TrainName = a.Name, TrainFullName = a.FullName, a.SystemId, a.CreatedDate, a.Remark, a.Id }).Search(keyword); if (!string.IsNullOrEmpty(ordering)) { model = model.OrderBy(ordering, null); } return(View(model.ToPagedList(pageIndex))); }
public async Task <IEnumerable <Train> > GetAll([FromQuery] TrainParameters trainParameters) { return(await _service.GetAll(trainParameters)); }