示例#1
0
        public ActionResult Create()
        {
            ViewBag.Makes = LoadDataUtils.LoadMakesData();
            ViewBag.Types = LoadDataUtils.LoadTypesData();

            return(View());
        }
示例#2
0
        public ActionResult Create(CarViewModel carVM)
        {
            try
            {
                using (CarServiceReference.CarClient service = new CarServiceReference.CarClient())
                {
                    CarDto carDto = new CarDto
                    {
                        //   Id = carVM.Id,
                        Model       = carVM.Model,
                        ReleaseYear = carVM.ReleaseYear,
                        HorsePower  = carVM.HorsePower,
                        Make        = new MakeDto
                        {
                            Id = carVM.MakeId
                        },
                        Type = new TypeDto
                        {
                            Id = carVM.TypeId
                        }
                    };
                    service.PostCar(carDto);
                }
                ViewBag.Makes = LoadDataUtils.LoadMakesData();
                ViewBag.Types = LoadDataUtils.LoadTypesData();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#3
0
        public ActionResult Edit(int id)
        {
            CarViewModel carVM = new CarViewModel();

            using (CarServiceReference.CarClient carService = new CarServiceReference.CarClient())
            {
                var carDto = carService.GetCarById(id);
                carVM = new CarViewModel(carDto);
            }

            ViewBag.Makes = LoadDataUtils.LoadMakesData();
            ViewBag.Types = LoadDataUtils.LoadTypesData();

            return(View(carVM));
        }