예제 #1
0
        public async Task <IActionResult> Create([Bind("Name,Abrv,MakeId")] CreateVehicleModel createVehicleModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var vehicleModel  = _mapper.Map <CreateVehicleModel, VehicleModel>(createVehicleModel);
                    var numberOfSaves = await _vehicleModelService.CreateVehicleModelAsync(vehicleModel);

                    return(RedirectToAction(nameof(Index), new { makeId = vehicleModel.MakeId }));
                }
                catch (Exception)
                {
                    return(RedirectToAction("Error", "Home"));
                }
            }

            return(View(createVehicleModel));
        }