/// <summary> /// Show main information profile /// </summary> /// <returns></returns> public async Task ShowParamsProfile() { ParamsList.Clear(); List <EditProfileData> profileDataEdit = new List <EditProfileData>(); EditProfilePageContent = await HttpRequest.GetRequestOnlinerAsync(UrlProfileEdit); resultat.LoadHtml(EditProfilePageContent); List <HtmlNode> editDataList = resultat.DocumentNode.Descendants().Where (x => (x.Name == "div" && x.Attributes["class"] != null && x.Attributes["class"].Value.Contains("uprofile-form"))).ToList(); var divList = editDataList[0].Descendants("div").ToList(); foreach (var item in divList) { if (item.InnerHtml.Contains("<input")) { ParamsList.Add(item.Descendants("input").FirstOrDefault().Attributes["value"].Value.ToString()); } else if (item.InnerHtml.Contains("<textarea")) { ParamsList.Add(item.Descendants("textarea").FirstOrDefault().InnerText); } else if (item.InnerHtml.Contains("<select")) { var selectList = item.Descendants("select").ToList(); bday = GetBirthDay(selectList); } } InputParamsProfile(); }
/// <summary> /// POST request for storing profile data /// </summary> public async void SaveEditProfile(List <object> ParamsList, BirthDayDate bday) { if (!HasInternet()) { throw new WebException(); } if (EditProfileToken == string.Empty) { EditProfileToken = await GetEditProfileToken(); } StringBuilder postData = new StringBuilder(); postData.Append("token=" + EditProfileToken + "&"); postData.Append("city=" + WebUtility.UrlEncode(ParamsList[0].ToString()) + "&"); postData.Append("occupation=" + WebUtility.UrlEncode(ParamsList[1].ToString()) + "&"); postData.Append("interests=" + ParamsList[2].ToString() + "&"); postData.Append("user_bday=" + bday.Day + "&"); postData.Append("user_bmonth=" + bday.Mounth + "&"); postData.Append("user_byear=" + bday.Year + "&"); postData.Append("jabber=" + ParamsList[3].ToString() + "&"); postData.Append("icq=" + ParamsList[4].ToString() + "&"); postData.Append("skype=" + ParamsList[5].ToString() + "&"); postData.Append("aim=" + ParamsList[6].ToString() + "&"); postData.Append("website=" + ParamsList[7].ToString() + "&"); postData.Append("blog=" + ParamsList[8].ToString() + "&"); postData.Append("devices=" + ParamsList[9].ToString() + "&"); postData.Append("signature=" + WebUtility.UrlEncode(ParamsList[10].ToString())); await PostRequestFormData(EdipProfile, "profile.onliner.by", "http://profile.onliner.by", postData.ToString()); }
/// <summary> /// Pars date information /// </summary> /// <param name="list"></param> /// <returns></returns> private BirthDayDate GetBirthDay(List <HtmlNode> list) { BirthDayDate bDay = new BirthDayDate(); bDay.Day = GetListParams(list[0].Descendants("option").ToList()); bDay.Mounth = GetListParams(list[1].Descendants("option").ToList()); bDay.Year = GetListParams(list[2].Descendants("option").ToList()); return(bDay); }
private bool ValidatePesel(string pesel) { if (pesel is null) { return(false); } try { var birthDay = new BirthDayDate { Year = int.Parse(pesel.Substring(0, 2)), Month = int.Parse(pesel.Substring(2, 2)), Day = int.Parse(pesel.Substring(4, 2)) }; return(birthDay.Month > 0 && birthDay.Month <= 12 && birthDay.Day > 0 && birthDay.Day <= 31); } catch { return(false); } }