コード例 #1
0
ファイル: MovieController.cs プロジェクト: Turrino/DVDLib
        public ActionResult DeleteIt(int id)
        {
            var repo = new Repo();

            repo.DeleteDVD(id);

            return RedirectToAction("Index", "Home");
        }
コード例 #2
0
ファイル: DALTests.cs プロジェクト: Turrino/DVDLib
        public void DeleteDVD_Top1_DeletedDVD_DoesNotShowUpInList(int ID_to_mark)
        {
            Settings set = new Settings(connectionString);
            Repo repo = new Repo();

            List<int> expectedIDs = new List<int>();

            repo.DeleteDVD(ID_to_mark);

            using (SqlConnection cn = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "SELECT * FROM DVDs WHERE Deleted IS NULL OR Deleted <> 1";
                cmd.Connection = cn;

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        expectedIDs.Add((int)dr["dvdID"]);
                    }
                }
            }

            Assert.IsTrue(!expectedIDs.Contains(ID_to_mark));

            repo.RestoreDVD(ID_to_mark);
        }