Beispiel #1
0
        public void GetDescriptionTest()
        {
            Link link = new Link("test2", "test2", "www.test.com");

            Assert.IsTrue(link.GetDescription() == "test2");
        }
Beispiel #2
0
        //Create and delete links in list and DB
        public bool CreateLink(Link link)
        {
            bool flag;
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "INSERT INTO [dbo].[Link] (Description, ProjectName, Address, RoadmapName) VALUES (@descrip,@Pname, @addr,@Rname)";
                    cmd.Parameters.AddWithValue("@descrip", link.GetDescription());
                    cmd.Parameters.AddWithValue("@Pname", mName);
                    cmd.Parameters.AddWithValue("@addr", link.GetLink());
                    cmd.Parameters.AddWithValue("@Rname", mRoadmapName);
                    cmd.Connection = conn;

                    conn.Open();
                    flag = cmd.ExecuteNonQuery() != 0;
                    conn.Close();
                }
            }
            return flag;
        }