コード例 #1
0
        public IActionResult CreateBus(BusParkViewModel newBus)
        {
            string busType = newBus.Type switch
            {
                "school" => "special",
                "administration" => "special",
                "special" => "special",
                "city" => "ordinary",
                "ordinary" => "ordinary",
                "touristic" => "touristic",
                _ => "special"
            };

            var bus = new Bus()
            {
                Model     = newBus.Model,
                Type      = newBus.Type,
                Capacity  = newBus.Capacity,
                Price     = newBus.Price,
                RoutePlan = _tripRouteRepository.GetByType(busType)
            };

            _busRepository.Save(bus);

            return(RedirectToAction("Index"));
        }
コード例 #2
0
ファイル: BusController.cs プロジェクト: K-Gulzada/Kz2021p1
        public IActionResult BusPark()
        {
            var model = new BusParkViewModel()
            {
                Model    = "ikar",
                Type     = "ordinary",
                Capacity = 100,
                Price    = 10
            };

            return(View(model));
        }
コード例 #3
0
ファイル: BusController.cs プロジェクト: K-Gulzada/Kz2021p1
        public IActionResult CreateBus(BusParkViewModel newBus)
        {
            var bus = new Bus()
            {
                Model    = newBus.Model,
                Type     = newBus.Type,
                Capacity = newBus.Capacity,
                Price    = newBus.Price
            };

            _busRepository.Save(bus);

            return(RedirectToAction("Index"));
        }