public void DvdEdit(DvdVM dvd) { using (var cn = new SqlConnection()) { cn.ConnectionString = ConfigurationManager.ConnectionStrings["DVDLibrary"].ConnectionString; var parameters = new DynamicParameters(); parameters.Add("@dvdId", dvd.dvdId); parameters.Add("@title", dvd.title); parameters.Add("@director", dvd.director); parameters.Add("@rating", dvd.rating); parameters.Add("@realeaseYear", dvd.realeaseYear); parameters.Add("@notes", dvd.notes); cn.Execute("DvdUpdate", parameters, commandType: CommandType.StoredProcedure); } }
public void DvdInsert(DvdVM dvd) { using (var cn = new SqlConnection()) { cn.ConnectionString = ConfigurationManager.ConnectionStrings["DVDLibrary"].ConnectionString; var parameters = new DynamicParameters(); parameters.Add("@dvdId", dbType: DbType.Int32, direction: ParameterDirection.Output); parameters.Add("@title", dvd.title); parameters.Add("@director", dvd.director); parameters.Add("@rating", dvd.rating); parameters.Add("@realeaseYear", dvd.realeaseYear); parameters.Add("@notes", dvd.notes); cn.Execute("DvdInsert", parameters, commandType: CommandType.StoredProcedure); dvd.dvdId = parameters.Get <int>("@dvdId"); } }