Exemple #1
0
        public bool DeleteLink(Link link)
        {
            bool flag;
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "DELETE FROM [dbo].[Link] WHERE RoadmapName = @Rname AND ProjectName = @Pname AND Address = @addr";
                    cmd.Parameters.AddWithValue("@Pname", mName);
                    cmd.Parameters.AddWithValue("@Rname", mRoadmapName);
                    cmd.Parameters.AddWithValue("@addr", link.GetLink());
                    cmd.Connection = conn;

                    conn.Open();
                    flag = cmd.ExecuteNonQuery() != 0;
                    conn.Close();
                }
            }
            mLinks.Remove(link);

            return flag;
        }
Exemple #2
0
        public void GetLinkTest()
        {
            Link link = new Link("test2", "test2", "www.test.com");

            Assert.IsTrue(link.GetLink()=="www.test.org");
        }
Exemple #3
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;
        }