Ejemplo n.º 1
0
        public ActionResult Search(string ipValue)
        {
            var repo = new Repo();

            List<DVD> results = repo.SearchForDVDTitle(ipValue);

            return View(results);
        }
Ejemplo n.º 2
0
        public void SearchByTitle_FullMatch(string fakeTitle)
        {
            DVD searchMe = new DVD()
            {
                Title = fakeTitle,
                CastMembers = new List<Cast>(),
            };

            Settings set = new Settings(connectionString);
            Repo repo = new Repo();

            int newID = repo.AddDVD(searchMe);
            int wantedID = 0;

            using (SqlConnection cn = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = $"SELECT TOP 1 * FROM DVDs WHERE Title = '{fakeTitle}' AND dvdID = {newID}";
                cmd.Connection = cn;

                cn.Open();

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

                List<DVD> results = repo.SearchForDVDTitle(fakeTitle);

                Assert.AreEqual(wantedID, results.FirstOrDefault().dvdID);

                DynamicParameters p = new DynamicParameters();
                p.Add("dvdID", newID);

                cn.Query("EraseDVDRecord", p, commandType: CommandType.StoredProcedure);
            }
        }