Beispiel #1
0
        public List <string> GetOverdue()
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand cmd = new SqlCommand("SELECT copy_id, due_date FROM checkout WHERE patron_id = @PatronId AND current_checkout = 1 AND due_date < @Today;", conn);

            cmd.Parameters.Add(new SqlParameter("@PatronId", this.GetId().ToString()));
            cmd.Parameters.Add(new SqlParameter("@Today", "2017-03-02"));

            SqlDataReader rdr = cmd.ExecuteReader();

            List <string> allDue = new List <string> {
            };

            while (rdr.Read())
            {
                int    copyId     = rdr.GetInt32(0);
                Copy   foundCopy  = Copy.Find(copyId);
                string foundTitle = foundCopy.GetBookTitle();
                allDue.Add(foundTitle);
                string dueDate = rdr.GetDateTime(1).ToString("yyyy-MM-dd");
                allDue.Add(dueDate);
            }

            DB.CloseSqlConnection(rdr, conn);

            return(allDue);
        }
Beispiel #2
0
        public void T5_Find_FindsCopyInDatabase()
        {
            Copy testCopy = new Copy(1);

            testCopy.Save();

            Copy foundCopy = Copy.Find(testCopy.GetId());

            Assert.Equal(testCopy, foundCopy);
        }
Beispiel #3
0
        public void Test_Find_FindsCopyInDatabase()
        {
            //Arrange
            Copy testCopy1 = new Copy(1, 15);

            testCopy1.Save();
            Copy testCopy2 = new Copy(2, 20);

            testCopy2.Save();

            //Act
            Copy result = Copy.Find(testCopy2.GetId());

            //Assert
            Assert.Equal(testCopy2, result);
        }