示例#1
0
        public ActionResult Edit(int id)
        {
            var Bus = DB.Buses.ToList().SingleOrDefault(c => c.Id == id);

            var Lines             = DB.Lines.ToList();
            BusLineViewModel blvm = new BusLineViewModel
            {
                Bus   = Bus,
                Lines = Lines
            };

            return(View(blvm));
        }
示例#2
0
        public ActionResult Index()
        {
            var Buses = DB.Buses.ToList();
            var Lines = DB.Lines.ToList();

            BusLineViewModel blvm = new BusLineViewModel
            {
                Lines = Lines,
                Buses = Buses
            };

            return(View(blvm));
        }
示例#3
0
        public ActionResult AddBus()
        {
            var Lines    = DB.Lines.ToList();
            var Days     = DB.Days.ToList();
            var BusTypes = DB.BusTypes.ToList();

            BusLineViewModel blvm = new BusLineViewModel
            {
                Lines    = Lines,
                Days     = Days,
                BusTypes = BusTypes
            };

            return(View(blvm));
        }
示例#4
0
        public ActionResult Details(int id)
        {
            var Bus  = DB.Buses.SingleOrDefault(c => c.Id == id);
            var Line = DB.Lines.SingleOrDefault(x => x.Id == Bus.LineId);

            if (Bus == null)
            {
                return(HttpNotFound());
            }
            BusLineViewModel blvm = new BusLineViewModel
            {
                Line = Line,
                Bus  = Bus
            };

            return(View(blvm));
        }
示例#5
0
 public ActionResult AddBus(BusLineViewModel blvm)
 {
     if (!ModelState.IsValid)
     {
         var Lines    = DB.Lines.ToList();
         var Days     = DB.Days.ToList();
         var BusTypes = DB.BusTypes.ToList();
         blvm.Lines    = Lines;
         blvm.Days     = Days;
         blvm.BusTypes = BusTypes;
         return(View("AddBus", blvm));
     }
     else
     {
         DB.Buses.Add(blvm.Bus);
         DB.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
示例#6
0
        public ActionResult Edit(BusLineViewModel blvm)
        {
            var lines = DB.Lines.ToList();

            if (!ModelState.IsValid)
            {
                blvm.Lines = lines;
                return(View("Edit", blvm));
            }
            var Bus = DB.Buses.Single(c => c.Id == blvm.Bus.Id);

            Bus.DriverName    = blvm.Bus.DriverName;
            Bus.LineId        = blvm.Bus.LineId;
            Bus.TimeFrom      = blvm.Bus.TimeFrom;
            Bus.TimeTo        = blvm.Bus.TimeTo;
            Bus.NumberOfSeats = blvm.Bus.NumberOfSeats;

            DB.SaveChanges();
            return(RedirectToAction("Index"));
        }