예제 #1
0
파일: Vote.cs 프로젝트: auxua/Qurvey
 public Vote(User user, Survey survey, Answer answer)
     : this()
 {
     this.User = user;
     this.Survey = survey;
     this.Answer = answer;
 }
예제 #2
0
 protected void SaveAnswer(Answer answer)
 {
     if (answer.Id == 0)
     {
         this.Answers.Add(answer);
     }
     else
     {
         this.Answers.Attach(answer);
     }
     this.SaveChanges();
 }
예제 #3
0
        async void createButton_Clicked(object sender, EventArgs e)
        {
            IsBusy = true;
            
            // verify data of field
            if ((editor.Text == "") || (e1.Text == "") || (e2.Text == ""))
            {
                Device.BeginInvokeOnMainThread(() => DisplayAlert("Error","Please provide at least a question and two options","OK") );
                IsBusy = false;
                return;
            }

            // Create data representation
            Answer a1 = new Answer(e1.Text, 0);
            Answer a2 = new Answer(e2.Text, 1);
            List<Answer> answers = new List<Answer>();
            answers.Add(a1);
            answers.Add(a2);
            if (e3.Text != "")
            {
                Answer a3 = new Answer(e3.Text, 2);
                answers.Add(a3);
            }
            if (e4.Text != "")
            {
                Answer a4 = new Answer(e4.Text, 3);
                answers.Add(a4);
            }
            Survey sur = new Survey(editor.Text.Trim());
            sur.Answers = answers;
            sur.Status = Survey.SurveyStatus.Published; //TODO: workflow for non-published surveys
			sur.Course = cid;

            // Send Survey to Server
            try
            {
                await api.Backend.SaveSurveyAsync(sur);
            }
            catch (Exception ex)
            {
                Device.BeginInvokeOnMainThread(() => DisplayAlert("Error", "An Error occured while saving the survey: " + ex.Message, "OK"));
                IsBusy = false;
                return;
            }

            // Everythin worked fine!
            Device.BeginInvokeOnMainThread(() => DisplayAlert("Success!", "The Survey was added", "OK"));
            IsBusy = false;

        }
예제 #4
0
파일: Result.cs 프로젝트: auxua/Qurvey
 public Result(Answer answer, int count)
     : this()
 {
     this.Answer = answer;
     this.Count = count;
 }
예제 #5
0
 public AnswerViewModel(Answer answer, Color backgroundColor)
 {
     Answer = answer;
     RaisePropertyChanged ("AnswerText");
     BackgroundColor = backgroundColor;
 }