Exemplo n.º 1
0
        public PollsPanelViewModel(INavigation navigation)
        {
            this.Navigation = navigation;

            if (GlobalVars.User == null || GlobalVars.User.isAdmin == false)
            {
                GoHome();
            }
            else
            {
                CloseWindowCommand  = new Command(CloseWindow);
                PostPollCommand     = new Command(PostPoll);
                AddOptionCommand    = new Command(AddOption);
                RemoveOptionCommand = new Command <string>(RemoveOption);
                Date          = DateTime.Now.ToString().Substring(0, 9);
                CreatedPollID = Guid.NewGuid().ToString().Substring(0, 8);

                PollOptions = new ObservableCollection <Option>();
                PollOptions.Add(new Option()
                {
                    PollID = CreatedPollID, OptionID = CreatedPollID.Substring(0, 8) + "_" + optionsCounter++, OptionPlaceHolder = "Option " + (optionsCounter).ToString()
                });
                PollOptions.Add(new Option()
                {
                    PollID = CreatedPollID, OptionID = CreatedPollID.Substring(0, 8) + "_" + optionsCounter++, OptionPlaceHolder = "Option " + (optionsCounter).ToString()
                });
                canCreatePoll = false;
            }
        }
Exemplo n.º 2
0
 private void AddOption()
 {
     if (PollOptions.Count < 10)
     {
         PollOptions.Add(new Option()
         {
             PollID = CreatedPollID, OptionID = CreatedPollID.Substring(0, 8) + "_" + optionsCounter++, OptionPlaceHolder = "Option " + (optionsCounter).ToString()
         });
         //optionsCounter++;
     }
     else
     {
         Application.Current.MainPage.DisplayAlert("Cannot Add Option", "You have reached the maximum number of options.", "Ok");
     }
 }