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); });
            }
        }
 private async void Button_Clicked_1(object sender, EventArgs e)
 {
     if (ts == 0)
     {
         await Application.Current.MainPage.Navigation.PushModalAsync(new StudentProfile ( studentm )).ConfigureAwait(false);
     }
     if (ts == 1)
     {
         OldStToNewSt chng = new OldStToNewSt();
         await Application.Current.MainPage.Navigation.PushModalAsync(new GetInstIDandRules ( chng.S_TO_Sc(studentm))).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();
                    }
                }
            });
        }
        private async void Button_Clicked(object sender, EventArgs e)
        {
            if (ms.isSent == true)
            {
                if (codeEntry.Text == vrNumber.ToString())
                {
                    if (ts == 0)
                    {
                        string     url      = "https://api.shikkhanobish.com/api/Master/RegisterStudent";
                        HttpClient client   = new HttpClient();
                        string     jsonData = JsonConvert.SerializeObject(new {
                            UserName          = studentm.UserName,
                            Password          = studentm.Password,
                            PhoneNumber       = studentm.PhoneNumber,
                            Name              = studentm.Name,
                            Age               = studentm.Age,
                            Class             = studentm.Class,
                            InstitutionName   = studentm.InstitutionName,
                            RechargedAmount   = 0,
                            IsPending         = 0,
                            TotalTuitionTime  = 0,
                            TotalTeacherCount = 0,
                            AvarageRating     = 0,
                        });
                        StringContent       content  = new StringContent(jsonData, Encoding.UTF8, "application/json");
                        HttpResponseMessage response = await client.PostAsync(url, content).ConfigureAwait(true);

                        string result = await response.Content.ReadAsStringAsync().ConfigureAwait(true);

                        Response responseData = JsonConvert.DeserializeObject <Response>(result);
                        LoginByUserNameAndPassword();
                    }
                    else if (ts == 1)
                    {
                        OldStToNewSt chng = new OldStToNewSt();
                        await Application.Current.MainPage.Navigation.PushModalAsync(new GetInstIDandRules( chng.S_TO_Sc(studentm))).ConfigureAwait(false);
                    }
                }
                else
                {
                    Msglbl.Text = "Code doesn't match! Try again.";
                    //92746
                }
            }
            else if (codeEntry.Text == null)
            {
                Msglbl.Text = "Enter the code";
            }
        }
Esempio n. 5
0
        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);
            });
        }