public void Create(Dvd dvd)
        {
            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["Dvds"].ConnectionString;

                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.CommandText = "InsertDvd";

                cmd.Parameters.AddWithValue("@Title", dvd.Title);
                cmd.Parameters.AddWithValue("@ReleaseYear", dvd.ReleaseYear);
                cmd.Parameters.AddWithValue("@Director", dvd.Director);
                cmd.Parameters.AddWithValue("@Rating", dvd.Rating);
                cmd.Parameters.AddWithValue("@Notes", dvd.Notes);

                conn.Open();
                cmd.ExecuteNonQuery();
            }
        }
 public Dvd Get(int dvdId)
 {
     dvd = _dvdRepository.Get(dvdId);
     return(dvd);
 }
示例#3
0
 public void Update(Dvd updatedDvd)
 {
     _dvds.RemoveAll(d => d.DvdId == updatedDvd.DvdId);
     _dvds.Add(updatedDvd);
 }