Beispiel #1
0
        public IActionResult Index(TicketDetailViewModel vm)
        {
            TicketDetailViewModel tvm = new TicketDetailViewModel();

            if (ModelState.IsValid)
            {
                Ticket ticket = ticketConverter.ViewModelToTicket(vm);

                if (trajectRepo.GetTrajectenbyStations(ticket.BeginStation.Id, ticket.EindStation.Id) != null)
                {
                    tvm = new TicketDetailViewModel
                    {
                        TrajectViewModel = new TrajectViewModel()
                    };
                    tvm.TrajectViewModel.Trajecten = trajectConverter.TrajectListToViewModelList(trajectRepo.GetTrajectenbyStations(ticket.BeginStation.Id, ticket.EindStation.Id)).ToList();
                    return(RedirectToAction("Reis", tvm));
                }
            }
            else
            {
                tvm = new TicketDetailViewModel
                {
                    StationViewModel = new StationViewModel()
                };
                tvm.StationViewModel.Stations = stationConverter.StationListToViewModelList(stationRepo.GetAllStations()).ToList();
            }
            return(View(tvm));
        }
Beispiel #2
0
 public IActionResult Create(TicketDetailViewModel vm)
 {
     if (ModelState.IsValid)
     {
         TicketViewModelConverter ticketViewModelConverter = new TicketViewModelConverter();
         Ticket  t  = ticketViewModelConverter.ViewModelToTicket(vm);
         decimal id = repo.CreateTicket(t);
         return(RedirectToAction("Details", new { id }));
     }
     return(View());
 }
Beispiel #3
0
 public IActionResult Edit(TicketDetailViewModel vm)
 {
     try
     {
         Ticket ticket = converter.ViewModelToTicket(vm);
         repo.UpdateTicket(ticket);
         return(RedirectToAction("Details", new { ticket.Id }));
     }
     catch
     {
         return(View());
     }
 }