コード例 #1
0
        //
        // GET: /Trip/

        public ActionResult Index()
        {
            var viewTrip = new TripDTO
            {
                TripList = repository.GetAllTrips(),
            };
            return View(viewTrip);
        }
コード例 #2
0
        public ActionResult Create(TripDTO tripDTO)
        {
            Trip trip = repository.CreateTrip(tripDTO);
            if (ModelState.IsValid)
            {
                db.Trips.Add(trip);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(trip);
        }
コード例 #3
0
        //
        // GET: /Trip/Details/5

        public ActionResult Details(int id)
        {
            Trip trip = repository.GetTrip(id);

            var tripView = new TripDTO
            {
                DepatureTime = trip.DepatureTime,
                TripPrice = trip.TripPrice,
            };

            if (tripView == null)
            {
                return HttpNotFound();
            }
            return View(tripView);
        }
コード例 #4
0
        public Models.Trip UpdateTrip(TripDTO tripTDO)
        {
            var trip = new Trip
            {
                TripId = tripTDO.TripId,
                DepatureTime = tripTDO.DepatureTime,
                TripPrice = tripTDO.TripPrice,
            };

            return trip;
        }
コード例 #5
0
        public Models.Trip CreateTrip(TripDTO tripDTO) // from Trip to TripDTO
        {
            var trip = new Trip
            {
                DepatureTime = tripDTO.DepatureTime,
                TripPrice = tripDTO.TripPrice,           
            };

            return trip;
        }
コード例 #6
0
 public ActionResult Edit(TripDTO tripDTO)
 {
     Trip trip = repository.UpdateTrip(tripDTO);
     if (ModelState.IsValid)
     {
         db.Entry(trip).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(trip);
 }