public ActionResult Create() { ViewBag.Makes = LoadDataUtils.LoadMakesData(); ViewBag.Types = LoadDataUtils.LoadTypesData(); return(View()); }
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()); } }
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)); }