public void AddTrails(AllTrails item) { using (IDbConnection dbConnection = Connection){ string sql = $@"INSERT INTO trails(trail_name, description, length, elevation, latitude, longitude)VALUES(@trail_name, @description, @length, @elevation, @latitude, @longitude)"; dbConnection.Open(); dbConnection.Execute(sql, item); } }
public IActionResult AddTrailtoDb(AllTrails trails) { if (ModelState.IsValid) { _dapperTrail.AddTrails(trails); return(RedirectToAction("Index")); } return(View("AddTrail")); }