Ejemplo n.º 1
0
        public async Task <GenericResponse> RegisterStudent(HelpsRegisterRequest request)
        {
            var response = helpsClient.PostAsJsonAsync("api/student/register", request).Result;

            if (response.IsSuccessStatusCode)
            {
                HelpsResponse decodedResponse = response.Content.ReadAsAsync <HelpsResponse>().Result;
                if (decodedResponse.IsSuccess)
                {
                    var user = userTable.CurrentUser();
                    user.HasLoggedIn = true;
                    AuthService     auth     = new AuthService();
                    GenericResponse Response = await auth.CompleteSetup(userTable.CurrentUser().StudentId);

                    if (Response.Success)
                    {
                        userTable.SetUser(user);
                        return(ResponseHelper.Success());
                    }
                }
                else
                {
                    return(ResponseHelper.CreateErrorResponse("Registration Failed", decodedResponse.DisplayMessage));
                }
            }
            return(ResponseHelper.CreateErrorResponse("Registration Failed", "An unknown error occurred"));
        }
Ejemplo n.º 2
0
        public async void Submit(View view)
        {
            ProgressDialog dialog = DialogHelper.CreateProgressDialog("Registering...", this);

            dialog.Show();
            RadioButton degreeIndex = (RadioButton)FindViewById(degree.CheckedRadioButtonId);
            RadioButton statusIndex = (RadioButton)FindViewById(status.CheckedRadioButtonId);

            try
            {
                var dob     = DateTime.ParseExact(year.Text + month.Text + date.Text, "yyyyMMdd", CultureInfo.InvariantCulture);
                var request = new HelpsRegisterRequest
                {
                    StudentId     = CurrentUser.StudentId,
                    DateOfBirth   = dob,
                    Degree        = degree.IndexOfChild(degreeIndex) + 1,
                    Status        = status.IndexOfChild(statusIndex),
                    FirstLanguage = language.SelectedItem.ToString(),
                    CountryOrigin = country.SelectedItem.ToString()
                };
                var Response = await Services.Student.RegisterStudent(request);

                dialog.Hide();
                if (Response.Success)
                {
                    var intent = new Intent(this, typeof(DashboardActivity));
                    StartActivity(intent);
                    Finish();
                }
                else
                {
                    DialogHelper.ShowDialog(this, Response.Message, Response.Title);
                }
            }
            catch (Exception)
            {
                dialog.Hide();
                DialogHelper.ShowDialog(this, "Error", "Please enter a valid date of birth");
            }
        }