private void SetRerateMoodViewData(ThoughtRecord thoughtRecord) { try { if (_linRerateItem != null) { _linRerateItem.RemoveAllViews(); foreach (var mood in thoughtRecord.RerateMoodList) { TextView rerateMoodName = (TextView)_activity.LayoutInflater.Inflate(Resource.Layout.VTextViewThought, null); var rerateMoodNameText = GetMoodName(mood.MoodListId) + ", " + mood.MoodRating.ToString() + "%"; SetTextItem(rerateMoodName, rerateMoodNameText); _linRerateItem.AddView(rerateMoodName); } } } catch (Exception e) { Log.Error(TAG, "SetRerateMoodViewData: Exception - " + e.Message); if (_activity != null) { if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(_activity, e, "Setting Rerate Mood Data", "ViewThoughtRecordsAdapter.SetRerateMoodViewData"); } } } }
public static void RemoveThoughtRecord() { try { Log.Info(TAG, "RemoveThoughtRecord: ThoughtRecordId - " + ThoughtRecordId.ToString()); if (ThoughtRecordId > 0) { Log.Info(TAG, "RemoveThoughtRecord: Id > 0, proceeding to remove"); var dbHelp = new Globals(); dbHelp.OpenDatabase(); ThoughtRecordItem.RemoveThisThoughtRecord(dbHelp.GetSQLiteDatabase()); dbHelp.CloseDatabase(); Log.Info(TAG, "RemoveThoughtRecord: Reset ThoughtRecordItem"); ThoughtRecordId = 0; ThoughtRecordItem = new ThoughtRecord(); //empty one for next use } if (ThoughtRecordId == 0) { Log.Info(TAG, "RemoveThoughtRecord: Skipped Removal, ID is zero!"); } } catch (System.Exception e) { Log.Error(TAG, "RemoveThoughtRecord: Error removing Thought Record with ID " + ThoughtRecordId.ToString() + " - " + e.Message); } }
private void SetAlternativeThoughtData(ThoughtRecord thoughtRecord) { try { if (_linAlternativeItem != null) { _linAlternativeItem.RemoveAllViews(); foreach (var alternativeThoughts in thoughtRecord.AlternativeThoughtsList) { TextView alternativeThought = (TextView)_activity.LayoutInflater.Inflate(Resource.Layout.VTextViewThought, null); var alternativeThoughtText = alternativeThoughts.Alternative + ", " + alternativeThoughts.BeliefRating.ToString() + "%"; SetTextItem(alternativeThought, alternativeThoughtText); _linAlternativeItem.AddView(alternativeThought); } } } catch (Exception e) { Log.Error(TAG, "SetAlternativeThoughtData: Exception - " + e.Message); if (_activity != null) { if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(_activity, e, "Setting Alternative Thought Records Data", "ViewThoughtRecordsAdapter.SetAlternativeThoughtData"); } } } }
private void SetEvidenceAgainstData(ThoughtRecord thoughtRecord) { try { if (_linEvidenceAgainstItem != null) { _linEvidenceAgainstItem.RemoveAllViews(); foreach (var evidenceAgainst in thoughtRecord.EvidenceAgainstHotThoughtList) { TextView evidenceAgainstValue = (TextView)_activity.LayoutInflater.Inflate(Resource.Layout.VTextViewThought, null); var evidenceAgainstText = evidenceAgainst.Evidence; SetTextItem(evidenceAgainstValue, evidenceAgainstText); _linEvidenceAgainstItem.AddView(evidenceAgainstValue); } } } catch (Exception e) { Log.Error(TAG, "SetEvidenceAgainstData: Exception - " + e.Message); if (_activity != null) { if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(_activity, e, "Setting Evidence Against Thought Data", "ViewThoughtRecordsAdapter.SetEvidenceAgainstData"); } } } }
private void SetAutomaticThoughtData(ThoughtRecord thoughtRecord) { try { if (_linAutomaticItem != null) { _linAutomaticItem.RemoveAllViews(); foreach (var automaticThoughts in thoughtRecord.AutomaticThoughtsList) { LayoutParams layoutParams = new TableLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); TextView automaticThought = (TextView)_activity.LayoutInflater.Inflate(Resource.Layout.VTextViewThought, null); automaticThought.LayoutParameters = layoutParams; automaticThought.SetPadding(0, 0, 5, 0); var autoText = automaticThoughts.Thought + (automaticThoughts.IsHotThought ? " " + _activity.GetString(Resource.String.HotThoughtTag) : ""); SetTextItem(automaticThought, autoText); _linAutomaticItem.AddView(automaticThought); } } } catch (Exception e) { Log.Error(TAG, "SetAutomaticThoughtData: Exception - " + e.Message); if (_activity != null) { if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(_activity, e, "Setting Automatic Thought Data", "ViewThoughtRecordsAdapter.SetAutomaticThoughtData"); } } } }
public void PopulateWithDefaultValues(ThoughtRecord thoughtRecord) { InitializeOrUpdateStringLoader("DefaultInputText"); thoughtRecord.Situation.DateTime = DateTime.Now; thoughtRecord.Emotions.Add(new Emotion { Name = stringLoader.GetString("EmotionExample"), InitialRating = 50, SubsequentRating = 50 }); thoughtRecord.Situation.Description = stringLoader.GetString("SituationDescription"); thoughtRecord.AutomaticThoughts = stringLoader.GetString("AutomaticThoughts"); thoughtRecord.SupportingEvidence = stringLoader.GetString("SupportingEvidence"); thoughtRecord.ContradictingEvidence = stringLoader.GetString("ContradictingEvidence"); thoughtRecord.RationalAssessment = stringLoader.GetString("RationalAssessment"); }
public void CreateNewThoughtRecord() { Title = newThoughtRecordTitle; thoughtRecord = new ThoughtRecord(); thoughtRecord.Situation = new Situation(); thoughtRecord.Emotions = new List <Emotion>(); DefaultInputText = thoughtRecordService.GetDefaultInputText(); thoughtRecordService.PopulateWithDefaultValues(thoughtRecord); observableEmotions = new ObservableCollection <Emotion>(thoughtRecord.Emotions); RegisterForEmotionChangeEvents(observableEmotions); observableEmotions.CollectionChanged += UpdateModelEmotionCollection; OnPropertyChanged(string.Empty); IsCurrentDataSaved = true; OnNewThoughtRecordCreated?.Invoke(this, new EventArgs()); }
public async Task <ActionResult <ThoughtRecordDto> > CreateThoughtRecord(int userId, CreateThoughtRecordDto createThoughtRecordDto) { var thoughtRecord = new ThoughtRecord { AlternativeThoughts = new Collection <AlternativeThought>(), AutomaticThoughts = new Collection <AutomaticThought>(), EvidenceAgainst = new Collection <EvidenceAgainstHotThought>(), EvidenceFor = new Collection <EvidenceForHotThought>(), Moods = new Collection <Mood>(), RecordDate = createThoughtRecordDto.RecordDate, ReRateMoods = new Collection <ReRateMood>(), Situation = new Collection <Situation>(), User = await _unitOfWork.UserRepository.GetUserByIdAsync(userId) }; _unitOfWork.ThoughtRecordRepository.AddItem(thoughtRecord); if (await _unitOfWork.Complete()) { return(Ok(_mapper.Map <ThoughtRecordDto>(thoughtRecord))); } return(BadRequest("Unable to create Thought Record")); }
public static void SetupDataFields() { try { ThoughtRecordId = 0; ThoughtRecordItem = new ThoughtRecord(); SituationItem = new Situation(); MoodItems = new List <Mood>(); MoodListItems = new List <MoodList>(); AutomaticThoughtsItems = new List <AutomaticThoughts>(); EvidenceForHotThoughtItems = new List <EvidenceForHotThought>(); EvidenceAgainstHotThoughtItems = new List <EvidenceAgainstHotThought>(); AlternativeThoughtsItems = new List <AlternativeThoughts>(); RerateMoodsItems = new List <RerateMood>(); ThoughtRecordsItems = new List <ThoughtRecord>(); Log.Info(TAG, "Exiting SetupDataFields with ThoughtRecordId = " + ThoughtRecordId.ToString()); } catch (System.Exception e) { Log.Error(TAG, "SetupDataFields: Error occurred initialising default data objects - " + e.Message); } }