コード例 #1
0
        public IActionResult Create([Bind("Id, Name")] VehicleType vehicleType)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _vehicleTypeRepository.AddEntity(vehicleType);
                    _vehicleTypeRepository.Commit();

                    return(RedirectToAction("Index"));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("Creating vehicle Type", "Failed to create a new vehicletype. " + ex.Message);
            }

            return(View(vehicleType));
        }