private void GetFantasiesData() { try { if (_fantasiesID != -1) { Log.Info(TAG, "GetFantasiesData: Attempting to find Fantasies with ID - " + _fantasiesID.ToString()); _fantasies = GlobalData.StructuredPlanFantasies.Find(feel => feel.FantasiesID == _fantasiesID); if (_fantasies == null) { Log.Error(TAG, "GetFantasiesData: _fantasies is NULL"); } } } catch (Exception e) { Log.Error(TAG, "GetFantasiesData: Exception - " + e.Message); if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorStructuredPlanFantasiesDialogGetData), "StructuredPlanFantasiesDialogActivity.GetFantasiesData"); } } }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { int fantasiesID = -1; string ofWhat = ""; int strength = -1; ConstantsAndTypes.REACTION_TYPE reaction = ConstantsAndTypes.REACTION_TYPE.Ambivalent; ConstantsAndTypes.ACTION_TYPE intention = ConstantsAndTypes.ACTION_TYPE.Maintain; string actionOf = ""; base.OnActivityResult(requestCode, resultCode, data); if (resultCode == Result.Ok) { try { if (data.HasExtra("fantasiesID")) { fantasiesID = data.GetIntExtra("fantasiesID", -1); } if (data.HasExtra("ofWhat")) { ofWhat = data.GetStringExtra("ofWhat"); } if (data.HasExtra("strength")) { strength = data.GetIntExtra("strength", -1); } if (data.HasExtra("reaction")) { reaction = (ConstantsAndTypes.REACTION_TYPE)data.GetIntExtra("reaction", -1); } if (data.HasExtra("intention")) { intention = (ConstantsAndTypes.ACTION_TYPE)data.GetIntExtra("intention", -1); } if (data.HasExtra("actionOf")) { actionOf = data.GetStringExtra("actionOf"); } Fantasies fantasiesItem = null; if (fantasiesID == -1) { //new item fantasiesItem = new Fantasies(); fantasiesItem.IsNew = true; fantasiesItem.IsDirty = false; } else { fantasiesItem = GlobalData.StructuredPlanFantasies.Find(fantasiesy => fantasiesy.FantasiesID == fantasiesID); fantasiesItem.IsNew = false; fantasiesItem.IsDirty = true; } fantasiesItem.OfWhat = ofWhat; fantasiesItem.Action = intention; fantasiesItem.ActionOf = actionOf; fantasiesItem.Strength = strength; fantasiesItem.Type = reaction; fantasiesItem.Save(); if (fantasiesID == -1) { GlobalData.StructuredPlanFantasies.Add(fantasiesItem); } UpdateAdapter(); } catch (Exception e) { Log.Error(TAG, "OnActivityResult: Exception - " + e.Message); if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorStructuredPlanFantasiesConfirm), "StructuredPlanFantasies.OnActivityResult"); } } } if (resultCode == Result.Canceled) { Toast.MakeText(this, Resource.String.StructuredplanNoChangesToast, ToastLength.Short).Show(); } }