public async Task <ActionResult> Create(ViewModelCarAdd car) { if (ModelState.IsValid) { await db.CarRepository.CreateCar(car); return(RedirectToAction("Index")); } return(View()); }
public async Task CreateCar(ViewModelCarAdd Car) { SqlCommand command = new SqlCommand("sp_CreateCar", _connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.AddWithValue("@transmission", Car.Transmission); command.Parameters.AddWithValue("@color", Car.Color); command.Parameters.AddWithValue("@price", Car.Price); command.Parameters.AddWithValue("@engine_type", Car.Engine_type); command.Parameters.AddWithValue("@body_type", Car.Body_type); command.Parameters.AddWithValue("@name", Car.Name); await command.ExecuteNonQueryAsync(); }