public async Task <ActionResult <EvidenceForHotThoughtDto> > CreateEvidenceForHotThought(int automaticThoughtId, CreateEvidenceForHotThoughtDto createEvidenceForHotThoughtDto) { var evidenceforhotthought = new EvidenceForHotThought { AutomaticThought = _mapper.Map <AutomaticThought>(await _unitOfWork.AutomaticThoughtRepository.GetItemAsync(automaticThoughtId)), Evidence = createEvidenceForHotThoughtDto.Evidence, ThoughtRecord = _mapper.Map <ThoughtRecord>(await _unitOfWork.ThoughtRecordRepository.GetItemAsync(createEvidenceForHotThoughtDto.ThoughtRecordId)) }; _unitOfWork.EvidenceForHotThoughtRepository.AddItem(evidenceforhotthought); if (await _unitOfWork.Complete()) { return(Ok(_mapper.Map <EvidenceForHotThoughtDto>(evidenceforhotthought))); } return(BadRequest("Unable to create Evidence For Hot Thought")); }
private void AddEvidenceForThought() { try { if (_evidenceText == null) { return; } if (string.IsNullOrWhiteSpace(_evidenceText.Text.Trim())) { var resourceString = GetString(Resource.String.evidenceForHotThoughtNoEvidence); _evidenceText.Error = resourceString; return; } EvidenceForHotThought thought = new EvidenceForHotThought(); thought.ThoughtRecordId = GlobalData.ThoughtRecordId; thought.Evidence = _evidenceText.Text.Trim(); if (GlobalData.EvidenceForHotThoughtItems == null) { GlobalData.EvidenceForHotThoughtItems = new List <EvidenceForHotThought>(); } GlobalData.EvidenceForHotThoughtItems.Add(thought); UpdateAdapter(); _evidenceText.Text = ""; } catch (Exception ex) { Log.Error(TAG, "AddEvidenceForThought_Click: Exception - " + ex.Message); if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(this, ex, GetString(Resource.String.ErrorAddingFor), "ThoughtRecordWizardEvidenceForHotThoughtStep.AddEvidenceForThought_Click"); } } }
public override View GetView(int position, View convertView, ViewGroup parent) { try { var view = convertView ?? _activity.LayoutInflater.Inflate(Resource.Layout.EvidenceForHotThoughtListItem, parent, false); var thought = view.FindViewById <TextView>(Resource.Id.txtEvidenceForHotThought); EvidenceForHotThought thoughtEntry = _evidenceForHotThoughtEntries.ElementAt(position); thought.Text = thoughtEntry.Evidence.Trim(); var parentHeldSelectedItemIndex = ((ThoughtRecordWizardEvidenceForHotThoughtStep)_activity).GetSelectedItem(); if (position == parentHeldSelectedItemIndex) { view.SetBackgroundColor(Color.Argb(255, 19, 75, 127)); thought.SetBackgroundColor(Color.Argb(255, 19, 75, 127)); } else { view.SetBackgroundDrawable(null); thought.SetBackgroundDrawable(null); } return(view); } catch (Exception e) { Log.Error(TAG, "GetView: Exception - " + e.Message); if (_activity != null) { if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(_activity, e, _activity.GetString(Resource.String.ErrorGetEvidenceForAdapterView), "EvidenceForHotThoughtItemsAdapter.GetView"); } } return(null); } }