public async Task<ResultMsg<Users>> SetUser( Users user) { try { using (var Client = new ApiClient ()) { var entity = JsonConvert.SerializeObject (user); var Result = await Client.PostAsync ("User/Register", new StringContent (entity, UnicodeEncoding.UTF8, "application/json")); var ResultJson = Result.Content.ReadAsStringAsync ().Result; var dato = JsonConvert.DeserializeObject<ResultMsg<Users>> (ResultJson); Client.Dispose (); return dato; } } catch (Exception) { return null; } }
public void SetUserDatos(Users datos) { var prefs = GetSharedPreferences (Application.PackageName, FileCreationMode.Private); var Edit = prefs.Edit (); Edit.PutString ("Datos_User", JsonConvert.SerializeObject(datos)); Edit.Commit (); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.PublicAcivity); ColorDrawable colorDrawable = new ColorDrawable (Color.ParseColor (Helpers.ColorHeader)); ActionBar.SetBackgroundDrawable (colorDrawable); WebView = FindViewById<WebView> (Resource.Id.Webview); ProGWebview = FindViewById<ProgressBar> (Resource.Id.ProGWebview); PrgBViews = FindViewById<ProgressBar> (Resource.Id.PrgBViews); LnYNext = FindViewById<LinearLayout> (Resource.Id.LnYNext); LnYNext.SetBackgroundColor (Color.ParseColor (Helpers.ColorHeader)); imageButton1 = FindViewById<ImageButton> (Resource.Id.imageButton1); imageButton2 = FindViewById<ImageButton> (Resource.Id.imageButton2); imageButton3 = FindViewById<ImageButton> (Resource.Id.imageButton3); imageButton4 = FindViewById<ImageButton> (Resource.Id.imageButton4); imageButton5 = FindViewById<ImageButton> (Resource.Id.imageButton5); TxtPuntosR=FindViewById<TextView>(Resource.Id.TxtPuntosR); TxtPuntosRR=FindViewById<TextView>(Resource.Id.TxtPuntosRR); PrgBViews.Max = 6; WebView.Settings.JavaScriptEnabled = true; WebView.Settings.LoadsImagesAutomatically = true; WebView.SetWebViewClient (new BulletinWebViewClient (this, ProGWebview)); imageButton1.Click+= (sender, e) => ValidaControl((ImageButton)sender); imageButton2.Click+= (sender, e) => ValidaControl((ImageButton)sender); imageButton3.Click+= (sender, e) => ValidaControl((ImageButton)sender); imageButton4.Click+= (sender, e) => ValidaControl((ImageButton)sender); imageButton5.Click+= (sender, e) => ValidaControl((ImageButton)sender); var telephonyManager = (TelephonyManager) GetSystemService(TelephonyService); Imei = telephonyManager.DeviceId; DatoUser = GetUserDatos (); }