public async Task <IActionResult> Save(SaveTruckDTO dto) { var models = await _modelService.ListModels(); models = models ?? new List <ModelDTO>(); ViewData["ModelId"] = new SelectList(models, "Id", "Name"); if (ModelState.IsValid) { if (dto.Id.HasValue) { var edited = await _truckService.EditTruck(dto); return(await ViewAsync(edited, "Truck", "Index")); } else { var truck = await _truckService.CreateTruck(dto); return(await ViewAsync(truck, "Truck", "Index")); } } return(View()); }