public async Task SearchStudent(string UserName, string Password) { string url = "https://api.shikkhanobish.com/api/Master/GetInfoByLogin"; HttpClient client = new HttpClient(); string jsonData = JsonConvert.SerializeObject(new { UserName = UserName, Password = Password }); StringContent content = new StringContent(jsonData, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync(url, content).ConfigureAwait(true); string result = await response.Content.ReadAsStringAsync(); var studentcl = JsonConvert.DeserializeObject <StudentClass> (result); OldStToNewSt convert = new OldStToNewSt(); var student = convert.Sc_TO_S(studentcl); MainThread.BeginInvokeOnMainThread(() => { loadinglbl.Text = "Logging As " + student.Name + "..."; }); if (student.IsPending == 1) { await progress.ProgressTo(.7, 300, Easing.SinIn).ConfigureAwait(false); string urlT = "https://api.shikkhanobish.com/api/Master/GetPending"; HttpClient clientT = new HttpClient(); string jsonDataT = JsonConvert.SerializeObject(new { StudentID = student.StudentID }); StringContent contentT = new StringContent(jsonDataT, Encoding.UTF8, "application/json"); HttpResponseMessage responseT = await clientT.PostAsync(urlT, contentT).ConfigureAwait(false); string resultT = await responseT.Content.ReadAsStringAsync(); var pendningRating = JsonConvert.DeserializeObject <IsPending> (resultT); urlT = "https://api.shikkhanobish.com/api/Master/GetInfoByTeacherID"; jsonDataT = JsonConvert.SerializeObject(new { TeacherID = pendningRating.TeacherID }); contentT = new StringContent(jsonDataT, Encoding.UTF8, "application/json"); responseT = await clientT.PostAsync(urlT, contentT).ConfigureAwait(false); resultT = await responseT.Content.ReadAsStringAsync(); var teacher = JsonConvert.DeserializeObject <Teacher> (resultT); TransferInfo trns = new TransferInfo(); trns.Student = student; trns.Class = pendningRating.Class; trns.Subject = pendningRating.Subject; trns.StudentCost = pendningRating.Cost; trns.StudyTimeInAPp = pendningRating.Time; trns.Teacher = teacher; StaticPageForOnSleep.isStudent = true; MainThread.BeginInvokeOnMainThread(() => { Application.Current.MainPage.Navigation.PushModalAsync(new RatingPage(trns, false)).ConfigureAwait(false); }); } else { StaticPageForOnSleep.isStudent = true; MainThread.BeginInvokeOnMainThread(async( ) => { await progress.ProgressTo(1, 300, Easing.SinIn).ConfigureAwait(false); }); MainThread.BeginInvokeOnMainThread(() => { Application.Current.MainPage.Navigation.PushModalAsync(new StudentProfile(student)).ConfigureAwait(false); }); } }
public async Task ConnectToServer( ) { _connection = new HubConnectionBuilder() .WithUrl(url) .Build(); await _connection.StartAsync(); isConnected = true; connectionStatus = "Connected"; _connection.Closed += async(s) => { isConnected = false; connectionStatus = "Disconnected"; await _connection.StartAsync(); isConnected = true; }; _connection.On <int, int, bool> ("SendStudentThatCallRecivedOrIgnored", async(studentID, teacherID, recivedOrNot) => { if (Info.Teacher.TeacherID == teacherID && Info.Student.StudentID == studentID) { if (recivedOrNot == true) { isAcceptedByTeacher = true; string urlT = "https://api.shikkhanobish.com/api/Master/GetInfoByStudentID "; HttpClient clientT = new HttpClient(); string jsonDataT = JsonConvert.SerializeObject(new { StudentID = Info.Student.StudentID }); StringContent contentT = new StringContent(jsonDataT, Encoding.UTF8, "application/json"); HttpResponseMessage responseT = await clientT.PostAsync(urlT, contentT).ConfigureAwait(false); string resultT = await responseT.Content.ReadAsStringAsync(); var studentClass = JsonConvert.DeserializeObject <StudentClass>(resultT); OldStToNewSt cn = new OldStToNewSt(); var student = cn.Sc_TO_S(studentClass); Info.Student = student; MainThread.BeginInvokeOnMainThread(() => { Application.Current.MainPage.Navigation.PushModalAsync(new TutionPage(Info)).ConfigureAwait(false); }); } else { isCallCut = true; isAcceptedByTeacher = true; await Application.Current.MainPage.Navigation.PopModalAsync(); _connection.StopAsync(); } } }); }
public async void backtoProfile() { StudentClass student = new StudentClass(); string url = "https://api.shikkhanobish.com/api/Master/GetInfoByLogin"; HttpClient client = new HttpClient(); string jsonData = JsonConvert.SerializeObject(new { UserName = info.Student.UserName, Password = info.Student.Password }); StringContent content = new StringContent(jsonData, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync(url, content).ConfigureAwait(false); string result = await response.Content.ReadAsStringAsync(); student = JsonConvert.DeserializeObject <StudentClass>(result); OldStToNewSt chng = new OldStToNewSt(); var countPagesToRemove = Application.Current.MainPage.Navigation.ModalStack.Count; Device.BeginInvokeOnMainThread(async( ) => { await Application.Current.MainPage.Navigation.PushModalAsync(new StudentProfile(chng.Sc_TO_S(student))).ConfigureAwait(false); }); }