public ActionResult CreateCar(Vehicle car) { var manager = new VehicleManager(); var response = manager.AddCar(car); return View("Home"); }
public void AddCar(Vehicle newCar) { using (var context = new DealershipContext()) { context.Vehicles.Add(newCar); context.SaveChanges(); } }
public Vehicle GetVehicleByID(int id) { var result = new Vehicle(); using (SqlConnection cn = new SqlConnection(Settings.ConnectionString)) { var p = new DynamicParameters(); p.Add("VehicleID", id); result = cn.Query<Vehicle>("SELECT * FROM Vehicle WHERE VehicleID = @VehicleID ", p).FirstOrDefault(); } return result; }
public Response<Vehicle> AddCar(Vehicle newCar) { var response = new Response<Vehicle>(); try { response.Success = true; response.Message = "A new car was added"; _repo.AddCar(newCar); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return response; }
public void AddVehicle(Vehicle vehicle) { int available = Convert.ToInt32(vehicle.IsAvailable); using (var connect = new SqlConnection(Settings.ConnectionString)) { var command = new SqlCommand("INSERT INTO Vehicle " + "(AdTitle, Description, Make, Milage, IsAvailable, Price, UrlPicture, Year) " + "VALUES (@AdTitle, @Description, @Make, @Milage, @IsAvailable, @Price, @UrlPicture, @Year)", connect); command.Parameters.Add(new SqlParameter("AdTitle", vehicle.AdTitle)); command.Parameters.Add(new SqlParameter("Description", vehicle.Description)); command.Parameters.Add(new SqlParameter("Make", vehicle.Make)); command.Parameters.Add(new SqlParameter("Milage", vehicle.Mileage)); command.Parameters.Add(new SqlParameter("IsAvailable", available)); command.Parameters.Add(new SqlParameter("Price", vehicle.Price)); command.Parameters.Add(new SqlParameter("UrlPicture", vehicle.UrlPicture)); command.Parameters.Add(new SqlParameter("Year", vehicle.Year.Date)); connect.Open(); command.ExecuteNonQuery(); } }
public HttpResponseMessage PostAddVehicle(Vehicle v) { return null; }
public ActionResult ViewPartial(Vehicle data) { return View("_ViewMore", data); }
public ActionResult AddCar(Vehicle c) { return View(); }