public async Task <IActionResult> Edit(Guid id) { Showroom showroom = await _showroomModel.GetById(id); var model = _mapper.Map <ShowroomEditViewModel>(showroom); return(View(model)); }
public async Task <IActionResult> Create(CarEditViewModel uniqueModelName) { if (!ModelState.IsValid) { var showrooms = await _showroomModel.GetAllActive(); uniqueModelName.SetList(showrooms); return(View(uniqueModelName)); } Car car = _mapper.Map <Car>(uniqueModelName); Showroom showroom = await _showroomModel.GetById(uniqueModelName.ShowroomId); await _carModel.Create(car); showroom.Cars.Add(car); await _showroomModel.Update(showroom); return(RedirectToAction(nameof(Details), new { id = car.Id })); }