Exemplo n.º 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"));
        }