public string InsertRegistrationInfo([FromBody] RegistrationObj r) { // inserts registration info try { DBConnect obj = new DBConnect(); SqlCommand objReg = new SqlCommand(); objReg.CommandType = CommandType.StoredProcedure; objReg.CommandText = "TP_InsertRegistration"; objReg.Parameters.AddWithValue("@userID", r.id); objReg.Parameters.AddWithValue("@photo", r.photo); objReg.Parameters.AddWithValue("@phone", r.phone); // if there are valid values for height and weight, add them to the command if (r.height != 0) { objReg.Parameters.AddWithValue("@height", r.height); } if (r.weight != 0) { objReg.Parameters.AddWithValue("@weight", r.weight); } objReg.Parameters.AddWithValue("@numChildren", r.numChildren); objReg.Parameters.AddWithValue("@wantKids", r.wantKids); objReg.Parameters.AddWithValue("@bio", r.bio); objReg.Parameters.AddWithValue("@movies", r.movies); objReg.Parameters.AddWithValue("@sayings", r.sayings); objReg.Parameters.AddWithValue("@restaurants", r.restaurants); objReg.Parameters.AddWithValue("@books", r.books); objReg.Parameters.AddWithValue("@songs", r.songs); objReg.Parameters.AddWithValue("@birthday", r.birthday); objReg.Parameters.AddWithValue("@gender", r.gender); objReg.Parameters.AddWithValue("@occupation", r.occupation); objReg.Parameters.AddWithValue("@seekingGender", r.seekingGender); objReg.Parameters.AddWithValue("@tagline", r.tagline); if (obj.DoUpdateUsingCmdObj(objReg, out string exception) == -2) { throw new Exception(exception); return(exception); } else { return("pass"); } } catch { return(null); } }
private Boolean AddRecords() { // search criteria --> all 5 tables IDictionary<string, List<string>> newValues = new Dictionary<string, List<string>> { ["religions"] = religions, ["commitments"] = commitments, ["interests"] = interests, ["likes"] = likes, ["dislikes"] = dislikes, }; JavaScriptSerializer js = new JavaScriptSerializer(); String jsonValues = js.Serialize(newValues); // update the details WebRequest request = WebRequest.Create(profileWebAPI + "update/details/" + Session["RegisteringUserID"].ToString()); request.Headers.Add("Authorization", "Bearer " + Session["token"].ToString()); request.Method = "POST"; request.ContentType = "application/json"; StreamWriter writer = new StreamWriter(request.GetRequestStream()); writer.Write(jsonValues); writer.Flush(); writer.Close(); WebResponse response = request.GetResponse(); Stream theDataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(theDataStream); String data = reader.ReadToEnd(); reader.Close(); response.Close(); if (data == "true") { showSuccessToast(); } else { showFailureToast(); } RegistrationObj reg = new RegistrationObj(); //reg.id = 10031; string ph = "images/person49.jpg"; reg.id = Convert.ToInt32(Session["RegisteringUserID"].ToString()); // profile photo table - serialized image string p = photoUpload.FileName; BinaryFormatter serializer = new BinaryFormatter(); MemoryStream memStream = new MemoryStream(); serializer.Serialize(memStream, p); Byte[] imgArray = memStream.ToArray(); reg.photo = imgArray; //profile private table string phoneNumber = txtNumber1.Text.ToString().Trim() + "-" + txtNumber2.Text.ToString().Trim() + "-" + txtNumber3.Text.ToString().Trim(); reg.phone = phoneNumber; int totalHeight; if (txtHeightFT.Text != "") { int n; bool bN3 = Int32.TryParse(txtHeightFT.Text, out n); if (bN3 && txtHeightIn.Text != "") { int inch; bN3 = Int32.TryParse(txtHeightIn.Text, out inch); if (bN3) { totalHeight = (12 * n) + inch; reg.height = totalHeight; } } else if (bN3) { totalHeight = (12 * n); reg.height = totalHeight; // height is stored in inches } } else { reg.height = 0; } int weight; if (txtWeight.Text != "") { int n; bool bN3 = Int32.TryParse(txtHeightFT.Text, out n); if (bN3) { weight = n; reg.weight = weight; } } else { reg.weight = 0; } int numChildren; if (txtNumKids.Text != "") { int n; bool bN3 = Int32.TryParse(txtHeightFT.Text, out n); if (bN3) { numChildren = n; reg.numChildren = numChildren; } } else { reg.numChildren = 0; } int wantKids; if (ddlWantChildren.SelectedValue == "1") { wantKids = 1; reg.wantKids = wantKids; } else { wantKids = 0; reg.wantKids = wantKids; } string bio = txtBio.Text; reg.bio = bio; string favMovies = txtFavMovies.Text; reg.movies = favMovies; string favSayings = txtFavSayings.Text; reg.sayings = favSayings; string favRestaurants = txtFavRestaurants.Text; reg.restaurants = favRestaurants; string favBooks = txtFavBooks.Text; reg.books = favBooks; string favSongs = txtFavSongs.Text; reg.songs = favSongs; // profile public table string birthday = txtBirthday.Text; reg.birthday = birthday; string gender = ddlGender.SelectedValue; reg.gender = gender; string occupation = ddlOccupation.SelectedValue; reg.occupation = occupation; string seekingGender = ddlSeeking.SelectedValue; reg.seekingGender = seekingGender; string tagline = txtTagline.Text; reg.tagline = tagline; string jsonR = js.Serialize(reg); WebRequest r = WebRequest.Create(profileWebAPI + "insert/registrationInfo"); r.Headers.Add("Authorization", "Bearer " + Session["token"].ToString()); r.Method = "POST"; r.ContentLength = jsonR.Length; r.ContentType = "application/json"; // Write the JSON data to the Web Request StreamWriter w = new StreamWriter(r.GetRequestStream()); w.Write(jsonR); w.Flush(); w.Close(); WebResponse rps = r.GetResponse(); Stream tDS = rps.GetResponseStream(); StreamReader rder = new StreamReader(tDS); String d = rder.ReadToEnd(); rder.Close(); rps.Close(); if (d == "pass") { return true; } return false; } // end add records