Exemplo n.º 1
0
        /**
        * Create a new user
        **/
        public bool CreateUser( User newuser )
        {
            bool toReturn = false;

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "INSERT INTO [dbo].[User] ( Name, ID, Email, Password ) VALUES (@Name,@User,@mail,@pass)";
                    cmd.Parameters.AddWithValue("@Name", newuser.GetName());
                    cmd.Parameters.AddWithValue("@User", newuser.GetUserName());
                    cmd.Parameters.AddWithValue("@mail", newuser.GetEmail());
                    cmd.Parameters.AddWithValue("@pass", newuser.GetPassword());
                    cmd.Connection = conn;

                    conn.Open();
                    if (cmd.ExecuteNonQuery()!=0)
                    {
                        toReturn = true;
                    }
                    conn.Close();
                }
            }
            return toReturn;
        }
Exemplo n.º 2
0
        public void UserTest()
        {
            User user = new User("NewName", "NewUserName", "NewEmail", "password");

            Assert.AreEqual("NewName", user.GetName());
            Assert.AreEqual("NewUserName", user.GetUserName());
            Assert.AreEqual("NewEmail", user.GetEmail());
            Assert.AreEqual("password", user.GetPassword());
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            mUser = new DB.User((string)Session["username"], (string)Session["password"]);
            name.InnerText = mUser.GetUserName() + "'s Roadmaps";
            searchtable.Rows.Clear();
            searchtable.Visible = false;
            createbutton.Enabled = false;
            //searchb.Enabled = true;

            if (Request.Form["username_ID"] != "" && Request.Form["password_ID"] != "") //FIX: Lets null login.  is useful though
                {
                    RocketRoadmap.DB.User user = new RocketRoadmap.DB.User(Request.Form["username_ID"], Request.Form["password_ID"]);
                    bool flag = user.Login();

                    if (flag)
                    {
                        Session["username"] = user.GetUserName();
                        Session["password"] = user.GetPassword();
                        mUser = new DB.User((string)Session["username"], (string)Session["password"]);
                        name.InnerText = user.GetUserName() + "'s Roadmaps";
                    }
                    else if (mUser.Login())
                    {
                    }

                    else
                    {
                        Response.Redirect("index.aspx", false);
                    }
                }
                else
                {
                    Response.Redirect("index.aspx", false);
                    return;
                }
                    if (mUser.Login())
                    {

                        RoadMaps umaps = new RoadMaps();

                        try
                        {
                            List<List<string>> uall = umaps.GetUserMapsInfo(mUser.GetUserName());
                            TableHeaderRow uhead = new TableHeaderRow();

                            TableHeaderCell u1 = new TableHeaderCell();
                            TableHeaderCell u2 = new TableHeaderCell();
                            TableHeaderCell u3 = new TableHeaderCell();
                            TableHeaderCell u4 = new TableHeaderCell();
                            TableHeaderCell u5 = new TableHeaderCell();
                            TableHeaderCell u6 = new TableHeaderCell();

                            u1.Text = "Name";
                            u1.Width = new Unit(20, UnitType.Percentage);
                            u2.Text = "Author";
                            u2.Width = new Unit(15, UnitType.Percentage);
                            u3.Text = "Description";
                            u3.Width = new Unit(40, UnitType.Percentage);
                            u4.Text = "Timestamp";
                            u4.Width = new Unit(20, UnitType.Percentage);
                            u5.Width = new Unit(5, UnitType.Percentage);

                            uhead.Cells.Add(u1);
                            uhead.Cells.Add(u2);
                            uhead.Cells.Add(u3);
                            uhead.Cells.Add(u4);
                            uhead.Cells.Add(u5);

                            userroadmaps.Rows.Add(uhead);

                            foreach (var umap in uall)
                            {
                                TableRow urow = new TableRow();

                                TableCell ucell_1 = new TableCell();
                                TableCell ucell_2 = new TableCell();
                                TableCell ucell_3 = new TableCell();
                                TableCell ucell_4 = new TableCell();
                                TableCell ucell_5 = new TableCell();

                                 HtmlInputButton deleteButton = new HtmlInputButton();
                                deleteButton.Value = "X";
                                deleteButton.Attributes.Add("onclick","AreYouSure(\""+umap[0]+"\");");

                                HyperLink link = new HyperLink();
                                link.NavigateUrl = "Roadmap.aspx?n=" + Uri.EscapeUriString(umap[0]);
                                link.Text = umap[0];

                                TableCell tCell1 = new TableCell();
                                ucell_1.Controls.Add(link);

                                ucell_2.Text = umap[1];
                                ucell_3.Text = umap[2];
                                ucell_4.Text = umap[3];

                                ucell_5.Controls.Add(deleteButton);

                                urow.Cells.Add(ucell_1);
                                urow.Cells.Add(ucell_2);
                                urow.Cells.Add(ucell_3);
                                urow.Cells.Add(ucell_4);
                                urow.Cells.Add(ucell_5);

                                userroadmaps.Rows.Add(urow);
                            }
                        }
                        catch (NullReferenceException nre)
                        {

                        }
                    }

                    RoadMaps maps = new RoadMaps();

                    try
                    {
                        List<List<string>> all = maps.GetAllMapsInfo();
                        TableHeaderRow uhead = new TableHeaderRow();

                        TableHeaderCell u1 = new TableHeaderCell();
                        TableHeaderCell u2 = new TableHeaderCell();
                        TableHeaderCell u3 = new TableHeaderCell();
                        TableHeaderCell u4 = new TableHeaderCell();
                        TableHeaderCell u5 = new TableHeaderCell();
                        TableHeaderCell u6 = new TableHeaderCell();

                        u1.Text = "Name";
                        u1.Width = new Unit(20, UnitType.Percentage);
                        u2.Text = "Author";
                        u2.Width = new Unit(15, UnitType.Percentage);
                        u3.Text = "Description";
                        u3.Width = new Unit(40, UnitType.Percentage);
                        u4.Text = "Timestamp";
                        u4.Width = new Unit(20, UnitType.Percentage);
                        u5.Width = new Unit(5, UnitType.Percentage);

                        uhead.Cells.Add(u1);
                        uhead.Cells.Add(u2);
                        uhead.Cells.Add(u3);
                        uhead.Cells.Add(u4);
                        uhead.Cells.Add(u5);

                        allroadmaps.Rows.Add(uhead);

                foreach (var map in all)
                        {
                            TableRow row = new TableRow();
                            TableCell cell_1 = new TableCell();
                            TableCell cell_2 = new TableCell();
                            TableCell cell_3 = new TableCell();
                            TableCell cell_4 = new TableCell();
                            TableCell cell_5 = new TableCell();
                            TableCell cell_6 = new TableCell();

                             HyperLink link = new HyperLink();
                            link.NavigateUrl = "Roadmap.aspx?n=" + map[0];
                            link.Text = map[0];

                           TableCell tCell1 = new TableCell();
                            cell_1.Controls.Add(link);

                            cell_2.Text = map[1];
                            cell_3.Text = map[2];
                            cell_4.Text = map[3];

                            row.Cells.Add(cell_1);
                            row.Cells.Add(cell_2);
                            row.Cells.Add(cell_3);
                            row.Cells.Add(cell_4);
                            row.Cells.Add(cell_5);

                        allroadmaps.Rows.Add(row);
                        }
                    }
                    catch (NullReferenceException nre)
                    {

                    }
        }