This is a migrated thread and some comments may be shown as answers.

Setting a loop for database entries into azure

2 Answers 42 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 14 Feb 2019, 10:13 AM

When i click the submit button and fire this code it inserts it into the databse correctly but seems to duplication depending on how many entries already exist. Is there a way i can set a loop or if statement to limit to one entry, i tried to do via the datetime but because the multiple entries go in a second apart it wont work. Any help appreciated.  Still a beginner in Xamarin. 

Some of my code included in my submit button click is :

 async Task AddInitialFeedback(string usersymptomid)
        {
           
            SymptomFeedback symptomFeedback = new SymptomFeedback();
            symptomFeedback.Usersymptomid = usersymptomid;
            symptomFeedback.Intensity = RatingSlider.Value.ToString();
            symptomFeedback.UserID = Helpers.Settings.UserKey;
            symptomFeedback.DateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
            symptomFeedback.Datetimelimit = DateTime.Now.AddMinutes(30).ToString("g");
            //  symptomFeedback.Symptomfeedback = Symptomfeedback.Text.ToString();
            

            try
            {

                await symptomfeedbackmanager.AddSymptomfeedback(symptomFeedback);

                //We have to null the id so that we are not always updating the existing feedback item
                symptomFeedback.Id = null;
            }
            catch (Exception ex)
            {
                Analytics.TrackEvent(ex.ToString());
            }
        }

2 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 14 Feb 2019, 04:27 PM
Hi Mark,

Thank you for providing the code, however, I'm not sure where the relationship is with any Telerik control. I'm going to take a guess and say that you used one of the screens templates?

This forum is for the Telerik controls and those controls features, general Xamarin programming questions posted on StackOverflow or the Xamarin Forums for better visibility for XAML and Xamarin programming advise.

I can give you a couple of ideas to get started:

- you can just disable the button when the user clicks the button. That way, they cannot click it again after submitting the feedback.

myButton.IsEnabled = false;


- Use a boolean flag to prevent resubmitting the feedback

if(preventSubmission)
    return;
 
await symptomfeedbackmanager.AddSymptomfeedback(symptomFeedback);


Good luck!

Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
liam
Top achievements
Rank 1
answered on 15 Mar 2019, 11:13 AM
Nice Post! I appreciate you for this post.
Tags
General Discussions
Asked by
Mark
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
liam
Top achievements
Rank 1
Share this question
or