Пример #1
0
        // GET: Trip
        public ActionResult Index()
        {
            TripFormAndSuperTripViewModel model = new TripFormAndSuperTripViewModel();

            model.tripFormModel = new TripFormModel(); // maybe add session here for get last search
            return(View(model));
        }
Пример #2
0
        public ActionResult GetTrain(TripFormModel model)
        {
            List <SuperTripViewModel> result = new List <SuperTripViewModel>();

            //model.DateOneWay = DateTime.ParseExact(model.DateOneWay.ToString(), "dd/MM/yyyy", null);

            /*string[] keys = Request.Form.AllKeys;
             * for (int i = 0; i < keys.Length; i++)
             * {
             *  System.Diagnostics.Debug.WriteLine(keys[i] + ": " + Request.Form[keys[i]] + "<br>");
             * }*/
            if (ModelState.IsValid)
            {
                //System.Diagnostics.Debug.WriteLine("ici");
                //call API

                result = GetTripFromApi(model.DepartOrArrivalOneWay, model.DepartureStation, model.ArrivalStation, model.DateOneWay, model.HourOneWay);
                foreach (var trip in result)
                {
                    trip.isReturn = false;
                }

                if (model.TripWay == false)
                {
                    List <SuperTripViewModel> tmp = GetTripFromApi(model.DepartOrArrivalReturn, model.ArrivalStation, model.DepartureStation, (DateTime)model.DateReturn, model.HourReturn);
                    foreach (var trip in tmp)
                    {
                        trip.isReturn = true;
                        result.Add(trip);
                    }
                }
            }

            Session["listProposition"] = result;

            TripFormAndSuperTripViewModel modelReturn = new TripFormAndSuperTripViewModel();

            modelReturn.tripFormModel      = model;
            modelReturn.superTripViewModel = result;


            return(View("Index", modelReturn));
        }