Currently on my application when i run it the code is working correctly, except when i add a 'symptom' that already belongs in the 'symptom history' , currently when i add a symptom which is already added in the symptom history the app gives out the message "Duplicate Symptom", "You already have recorded this symptom" and "Historical Symptom", "This symptom is in your history - Please restore from here". How can i get to it to only display "Historical Symptom", "This symptom is in your history - Please restore from here" message.
Currently if the symptom isnt deleted and moved to the symptom history the app will only output the "Duplicate Symptom", "You already have recorded this symptom" message corrrectly.
The functionality is working correctly just need to only display that one message on the function instead of both of them.
This is the current code on my button:
async void btnAdd_Clicked(object sender, EventArgs e)
{
CheckSymptomInHistory(AutoCompleteSymptomToAdd.Id);
//If the autocomplete is not empty - add that symptom to the user symptom table
if (AutoCompleteSymptomToAdd != null)
{
//If the user already has symptoms, loop through them to make sure that they are not adding a duplicate
if (UserSymptoms.Count > 0)
{
foreach (usersymptom item in UserSymptoms)
{
if (item.Symptomid == AutoCompleteSymptomToAdd.Id)
{
await DisplayAlert("Duplicate Symptom", "You already have recorded this symptom", "OK");
return;
}
//Check if it is not active (i.e in SYmptom History)
else
{
UserSymptomToAdd.Symptomid = AutoCompleteSymptomToAdd.Id;
UserSymptomToAdd.UserID = Helpers.Settings.UserKey;
UserSymptomToAdd.Datetimeadded = DateTime.Now.ToString();
UserSymptomToAdd.IsActive = true;
try
{
await usersymptommanager.AddUserSymptom(UserSymptomToAdd);
await AddInitialFeedback(UserSymptomToAdd.Id);
//await DisplayAlert("Symptom Added", "Your Symptom has been added", "OK");
}
catch (Exception ex)
{
Analytics.TrackEvent("App Screen: " + Title + ": " + ex);
//await DisplayAlert("Error", ex.ToString(), "OK");
}
}
}
}
The code for my history message:
async void CheckSymptomInHistory(string id)
{
foreach (string item in SymptomHistoryIDs)
{
if (id == item)
{
await DisplayAlert("Historical Symptom", "This symptom is in your history - Please restore from here", "OK");
}
}
}
Aucun commentaire:
Enregistrer un commentaire