Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.HomeScreen);

            Button profile = FindViewById <Button> (Resource.Id.ProfileButton);


            var user = Intent.GetStringExtra("user");
            var key  = Intent.GetStringExtra("key");

            Console.WriteLine(user + " @@@@@ " + key);

            LoginResponse data = new LoginResponse(user, key);

            profile.Click += async(sender, e) => {
                var             Pgetter = new ProfileUtility();
                ProfileResponse result  = await Pgetter.ProfileAsync(data);

                Intent intent = new Intent(this, typeof(StudentProfile));
                var    b      = new Bundle();
                b.PutString("fname", result.fname);
                b.PutString("lname", result.lname);
                b.PutString("major", result.major);
                b.PutString("email", result.email);
                b.PutString("gender", result.gender);
                b.PutString("year", result.year);
                b.PutString("age", result.age.ToString());
                intent.PutExtras(b);
                StartActivity(intent);
            };

            // Create your application here
        }
        public Task <ProfileResponse> ProfileAsync(LoginResponse data)
        {
            return(Task.Run(() => {
                var client = new RestClient("http://70.187.52.39:3000/ProfileApp");
                var req = new RestRequest(Method.POST);



                var json = req.JsonSerializer.Serialize(data);
                req.AddParameter("application/json; charset=utf-8", json, ParameterType.RequestBody);
                //Console.WriteLine ("HELLLOOOO!>>?????");
                var returnStuff = client.Execute(req);
                ProfileResponse info = JsonConvert.DeserializeObject <ProfileResponse> (returnStuff.Content);
                Console.WriteLine(info);

                //var dict = JsonConvert.DeserializeObject<JsonArrayAttribute> (asd);
                return info;
            }));
        }