//Button to Commit changes made - Function checks Fields entered
        protected void submit_userchanges_Click(object sender, EventArgs e)
        {
            UserServicesSoapClient ws = new UserServicesSoapClient();
            string username           = Request.Cookies["User"].Value;
            int    userID             = ws.getUserID(username);

            if (edit_email_textBox.Text != "")
            {
                ws.updateEmail(userID, edit_email_textBox.Text);
                Response.Redirect("myProfile.aspx");
            }

            if (edit_username_textbox.Text != "")
            {
                ws.updateUsername(userID, edit_username_textbox.Text);
                Response.Cookies["userId"].Value   = null;
                Response.Cookies["User"].Value     = null;
                Response.Cookies["LoggedIn"].Value = "false";
                Response.Redirect("Login.aspx");
            }



            if (edit_firstname_textbox.Text != "")
            {
                ws.updateFirstname(userID, edit_firstname_textbox.Text);
                Response.Redirect("myProfile.aspx");
            }
        }
        // Login on user uplon click Logon button
        protected void login_button_click(object sender, EventArgs e)
        {
            if (Request.Cookies["LoggedIn"] != null && Request.Cookies["LoggedIn"].Value == "true")
            {
                Request.Cookies["LoggedIn"].Value = "false";
            }
            UserServicesSoapClient login_ws = new UserServicesSoapClient();

            if (login_ws.userLogin(username_textbox.Text, password_textbox.Text) == false)
            {
                login_label.Visible = true;
            }

            //USer logged in successfully
            else
            {
                HttpCookie loggedInCookie = new HttpCookie("LoggedIn", "true");
                Response.Cookies.Add(loggedInCookie);



                HttpCookie userCookie = new HttpCookie("User", username_textbox.Text);
                Response.Cookies.Add(userCookie);

                string     username     = username_textbox.Text;
                int        userId       = login_ws.getUserID(username);
                HttpCookie userIdCookie = new HttpCookie("userId", userId.ToString());
                Response.Cookies.Add(userIdCookie);

                Response.Redirect("MyRecipes.aspx");
            }
        }
Beispiel #3
0
 //Checked if user is logged in
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.Cookies["LoggedIn"] != null && Request.Cookies["LoggedIn"].Value == "true")
     {
         UserServicesSoapClient ws = new UserServicesSoapClient();
         string username           = Request.Cookies["User"].Value;
         int    userID             = ws.getUserID(username);
     }
     else
     {
         Response.Redirect("Index.aspx");
     }
 }
Beispiel #4
0
        //Add recipe, validation is done by validation controls
        protected void add_recipe_button_Click(object sender, EventArgs e)
        {
            UserServicesSoapClient ws = new UserServicesSoapClient();
            int     totalRatings      = 0;
            int     rating            = 0;
            decimal avgRating         = 0;

            string username = Request.Cookies["User"].Value;
            int    userID   = ws.getUserID(username);

            Console.WriteLine(userID);
            byte[] ingredients_bytes = System.Text.Encoding.ASCII.GetBytes(add_recipe_intgredients_textbox.Text);
            recipeAdded_label.Text = ingredients_bytes.ToString();
            byte[] method_bytes = System.Text.Encoding.ASCII.GetBytes(add_recipe_method_textbox.Text);
            ws.InsertRecipeService(add_recipe_name_textbox.Text, add_recipe_intgredients_textbox.Text, add_recipe_method_textbox.Text, userID, totalRatings, rating, avgRating);
            recipeAdded_label.Text = "Recpie Added";
        }