コード例 #1
0
        public ActionResult AddVehicle(VehicleVM m)
        {
            if (ModelState.IsValid)
            {
                var newCar = new Car
                {
                    CarYear    = m.Year,
                    Exterior   = m.Color,
                    Interior   = m.Interior,
                    Sold       = null,
                    IsNew      = m.IsNew,
                    IsFeatured = false,
                    IsManual   = !m.IsAutomatic,
                    Mileage    = m.Mileage,
                    MSRP       = m.MSRP,
                    Price      = m.Price,
                    VIN        = m.VIN,
                    Model      = new CarModel
                    {
                        ModelId = m.Model.ModelId
                    },
                };
                repo.AddCar(newCar);

                return(RedirectToAction("Index"));
            }
            m.PopulateMakeList(repo);
            m.PopulateModelList(repo);
            m.PopulateStyleList(repo);

            return(View(m));
        }
コード例 #2
0
        public IActionResult Create(Car car)
        {
            if (car.Id == 0)
            {
                car.Id = _carRepo.GetNewCarId();
            }

            if (ModelState.IsValid)
            {
                _carRepo.AddCar(car);
                return(RedirectToAction("Index"));
            }
            return(View(car));
        }
コード例 #3
0
        public bool ParkCar(int level, int spot, Car car)
        {
            if (isSpaceAvailable(level, spot))
            {
                var parkingSpace = pRepo.GetParkingSpaceByLevelAndSpot(level, spot);

                if (parkingSpace.ParkingType == car.ParkingType)
                {
                    car.Id = cRepo.AddCar(car);
                    pRepo.AddParkingInstance(car.Id, parkingSpace.Id);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
 public ActionResult <CarModel> AddNewCar(CarModel car)
 {
     return(Ok(_carRepo.AddCar(car)));
 }