public int SaveCarVideo(CarVideos model) { using (IDbConnection connection = OpenConnection(dataConnection)) { string sql = @"INSERT INTO CarVideos(carId, vidURL, vidCourtsy, vidDescription, vidTypeId, createDate) values(@CrId, @vidURL, @vidCourtsy, @vidDescription, @vidTypeId, @createDate)"; model.createDate = DateTime.Now; int rowsAffected = connection.Execute(sql, model); return(rowsAffected); } }
public ActionResult Create(CarVideos model) { if (ModelState.IsValid) { model.vidURL = model.vidURL.Replace("https://youtu.be/", "https://www.youtube.com/embed/"); MasterRepository repo = new MasterRepository(); repo.SaveCarVideo(model); return(RedirectToAction("Create")); } else { return(View(model)); } }