public ActionResult AddNew(VehilceModelViewModel vehilceModelViewModel) { try { if (ModelState.IsValid) { string str = vehilceModelViewModel.VehicleModel; VehicleModelRepository vehicleModelRepository = new VehicleModelRepository(new AutoSolutionContext()); bool IsExist = vehicleModelRepository.isExist(vehilceModelViewModel.VehicleModel); if (!IsExist) { VehicleModel vehicleModel = new VehicleModel(); vehicleModel.VehicleModelName = vehilceModelViewModel.VehicleModel; vehicleModel.YearOfManufacture = vehilceModelViewModel.YearOfManufacture; vehicleModel.VehicleManufacturerId = Convert.ToInt32(vehilceModelViewModel.SelectedVehicleManufacturer); _unitOfWork.VehicleModel.Add(vehicleModel); _unitOfWork.Complete(); _unitOfWork.Dispose(); return(RedirectToAction("GetVehicleModel")); } else { return(RedirectToAction("GetVehicleModel")); } } } catch (Exception) { throw; } return(View()); }