Пример #1
0
        protected void Create_Click(object sender, EventArgs e)
        {
            pro                      = new UProfile();
            pro.userID               = u.UserID;
            pro.uPastProjectName     = txtPastProjectName.Text;
            pro.uPastProjectDuration = txtPastProjectDuration.Text;
            pro.uPastProjectDetails  = txtPastProjectDetails.Text;
            pro.uEducation           = txtEducation.Text;
            pro.uReferences          = txtReferences.Text;
            //pro.uSkills = txtSkills.Text;
            pro.uCountry = txtCountry.Text;
            pro.uName    = txtName.Text;
            pro.uSurname = txtSurname.Text;


            string              data    = JsonConvert.SerializeObject(pro);
            StringContent       content = new StringContent(data, Encoding.UTF8, "application/json");
            HttpResponseMessage resp    = client.PostAsync(client.BaseAddress + "/AddProfile", content).Result;

            u.FirstLogin = "******";


            string              uData    = JsonConvert.SerializeObject(u);
            StringContent       uContent = new StringContent(uData, Encoding.UTF8, "application/json");
            HttpResponseMessage respnse  = client.PutAsync(client.BaseAddress + "/UpdateUser/" + u.UserID, uContent).Result;


            if (resp.IsSuccessStatusCode)
            {
                Session["userID"] = u.UserID;
                Response.Redirect("~/Homepage/Homepage");
            }
            Response.Redirect("~/GiggerProfile");
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Create.Enabled     = false;
            Update.Enabled     = false;
            client.BaseAddress = baseAddress;

            int userID = (int)Session["UserID"];

            if (userID.Equals(null))
            {
                Response.Redirect("~/Account/Login");
            }

            HttpResponseMessage resp = client.GetAsync(client.BaseAddress + "/GetUserByID/" + userID).Result;

            if (resp.IsSuccessStatusCode)
            {
                string data = resp.Content.ReadAsStringAsync().Result;
                u = new UserModel(JsonConvert.DeserializeObject <UserModel>(data));

                if (u.FirstLogin == "False")
                {
                    Update.Enabled = true;
                    HttpResponseMessage res = client.GetAsync(client.BaseAddress + "/GetUserProfile/" + u.UserID).Result;
                    if (res.IsSuccessStatusCode)
                    {
                        string objectPro = res.Content.ReadAsStringAsync().Result;

                        profile = new UProfile(JsonConvert.DeserializeObject <UProfile>(objectPro));


                        txtCountry.Text   = profile.uCountry;
                        txtEducation.Text = profile.uEducation;
                        txtName.Text      = profile.uName;
                        txtSurname.Text   = profile.uSurname;
                        //txtSkills.Text = profile.uSkills;
                        txtReferences.Text          = profile.uReferences;
                        txtPastProjectName.Text     = profile.uPastProjectName;
                        txtPastProjectDuration.Text = profile.uPastProjectDuration;
                        txtPastProjectDetails.Text  = profile.uPastProjectDetails;
                    }
                }
                Create.Enabled = true;
            }
            else
            {
                ErrorM.Visible = true;
            }


            txtEmail.Text = u.uEmail;
        }