예제 #1
0
        private async void PostSurveysByNames(string UserName)
        {
            SurveysServices S_S = new SurveysServices();

            S_S.Set_UrlApi("ShareSurveys/" + UserName);
            await S_S.PostSurveysAsync(_survey);
        }
예제 #2
0
        public async Task UploadResponsedSurveys()
        {
            folder = FileSystem.Current.LocalStorage;
            if (!CheckNetwork.Check_Connectivity())
            {
                return;
            }
            List <Survey>        surveys = new List <Survey>();
            ExistenceCheckResult result  = await folder.CheckExistsAsync("ShareResponsedSurveys");

            if (result == ExistenceCheckResult.FolderExists)
            {
                folder = await folder.CreateFolderAsync("ShareResponsedSurveys", CreationCollisionOption.OpenIfExists);

                file = await folder.CreateFileAsync("ShareResponsedSurveys", CreationCollisionOption.OpenIfExists);

                string Content = await file.ReadAllTextAsync();

                if (String.IsNullOrEmpty(Content) || String.IsNullOrWhiteSpace(Content))
                {
                    return;
                }
                surveys = Serializable_Survey.deserialize(Content).ToList();
                foreach (Survey S in surveys)
                {
                    SurveysServices S_S = new SurveysServices();
                    S_S.Set_UrlApi("ShareResponsedSurveys/");
                    await S_S.PostSurveysAsync(S);
                }
                file = await folder.GetFileAsync("ShareResponsedSurveys");

                await file.DeleteAsync();
            }
        }
        private async void Delete_Item(int i)
        {
            var res = await DisplayAlert(Lang.Resource.titleMessage, Lang.Resource.DetailsDeleting, Lang.Resource.btnOkMessage, Lang.Resource.btnCancelMessage);

            if (res && CheckNetwork.Check_Connectivity())
            {
                stackQuestions.Children.RemoveAt(i + 1);
                survey.Questions_Property.RemoveAt(i);

                folder = FileSystem.Current.LocalStorage;

                folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.OpenIfExists);

                file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.OpenIfExists);

                string content = await file.ReadAllTextAsync();

                ListSurveys = Serializable_Survey.deserialize(content);
                foreach (Survey S in ListSurveys)
                {
                    if (S.Id == survey.Id)
                    {
                        S.Questions_Property = survey.Questions_Property;

                        SurveysServices S_S = new SurveysServices();
                        S_S.Set_UrlApi("EditSurveys/" + username);
                        await S_S.PutSurveysAsync(survey);

                        DrowItems(S);
                    }
                }
                content = Serializable_Survey.serialize(ListSurveys.ToList());
                await file.WriteAllTextAsync(content);
            }
        }
예제 #4
0
        private async void ReceiveSurveys()
        {
            SurveysServices S_S1        = new SurveysServices();
            ControlFile     controlFile = new ControlFile();
            string          username    = await controlFile.GetUserName();

            S_S1.Set_UrlApi("ReceiveSurveysShared/" + username);
            List <Survey> ReceivedSurveys = await S_S1.GetSurveysAsync();

            ExistenceCheckResult result = await folder.CheckExistsAsync("Receivedsurveys");

            if (result == ExistenceCheckResult.FolderExists)
            {
                folder = await folder.CreateFolderAsync("Receivedsurveys", CreationCollisionOption.OpenIfExists);

                file = await folder.CreateFileAsync("Receivedsurveys", CreationCollisionOption.OpenIfExists);

                string Content = await file.ReadAllTextAsync();

                List <Survey> OldreceiveSurveys = Serializable_Survey.deserialize(Content).ToList();
                if (OldreceiveSurveys.Count < ReceivedSurveys.Count)
                {
                    var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                    player.Load("NotificationReceive.mp3");
                    player.Play();

                    Plugin.LocalNotifications.CrossLocalNotifications.Current.Show(Lang.Resource.receivesurveys, Lang.Resource.BodyreceiveSurvey, 0);
                }
            }
            else if (result != ExistenceCheckResult.FolderExists && ReceivedSurveys.Count > 0)
            {
                var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                player.Load("NotificationReceive.mp3");
                player.Play();

                Plugin.LocalNotifications.CrossLocalNotifications.Current.Show(Lang.Resource.receivesurveys, Lang.Resource.BodyreceiveSurvey, 0);
            }
            folder = FileSystem.Current.LocalStorage;
            folder = await folder.CreateFolderAsync("Receivedsurveys", CreationCollisionOption.ReplaceExisting);

            file = await folder.CreateFileAsync("Receivedsurveys", CreationCollisionOption.ReplaceExisting);

            string content = Serializable_Survey.serialize(ReceivedSurveys);
            await file.WriteAllTextAsync(content);
        }
        private async void Save(object sender, EventArgs e)
        {
            if (!CheckNetwork.Check_Connectivity())
            {
                return;
            }

            stackQuestions.Opacity      = 0.5;
            ActivityIndicator.IsRunning = true;

            folder = FileSystem.Current.LocalStorage;
            folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.OpenIfExists);

            file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.OpenIfExists);

            string content = await file.ReadAllTextAsync();

            ListSurveys = Serializable_Survey.deserialize(content);
            foreach (Survey S in ListSurveys)
            {
                if (S.Id == survey.Id)
                {
                    S.Title_Property       = Title.Text;
                    S.Description_Property = Description.Text;

                    survey = S;
                    SurveysServices S_S = new SurveysServices();
                    S_S.Set_UrlApi("EditSurveys/" + username);
                    await S_S.PutSurveysAsync(survey);

                    break;
                }
            }
            title.Text       = Title.Text;
            description.Text = Description.Text;
            content          = Serializable_Survey.serialize(ListSurveys.ToList());
            await file.WriteAllTextAsync(content);

            Cancel(sender, e);

            await Task.Delay(500);

            ActivityIndicator.IsRunning = false;
            stackQuestions.Opacity      = 1;
        }
예제 #6
0
        private async void Delete_MenuItem_Clicked(object sender, EventArgs e)
        {
            var menuItem = sender as MenuItem;

            if (menuItem != null)
            {
                var survey = menuItem.BindingContext as Survey;
                var result = await DisplayAlert(Lang.Resource.deleting, Lang.Resource.detailsMessageDeleteSurvey + survey.Title_Property + Lang.Resource.survey, Lang.Resource.btnCancelMessage, Lang.Resource.btnOkMessage);

                if (result)
                {
                    return;
                }
                if (CheckNetwork.Check_Connectivity())
                {
                    SurveysServices S_S = new SurveysServices();
                    S_S.Set_UrlApi("DeleteSurvey/" + survey.Id + "/" + survey.User);
                    await S_S.DeleteSurveysAsync();

                    folder = FileSystem.Current.LocalStorage;
                    folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.OpenIfExists);

                    file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.OpenIfExists);

                    string content = await file.ReadAllTextAsync();

                    ListSurveys = Serializable_Survey.deserialize(content).ToList();
                    for (int i = 0; i < ListSurveys.Count; i++)
                    {
                        if (ListSurveys[i].Id == survey.Id)
                        {
                            ListSurveys.RemoveAt(i);
                        }
                    }
                    content = Serializable_Survey.serialize(ListSurveys);
                    await file.WriteAllTextAsync(content);

                    Full_Lists_Surveys();
                }
            }
        }
예제 #7
0
        private async void HandleConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
        {
            if (e.IsConnected)
            {
                string Content;
                // Post Responsed Surveys
                folder = FileSystem.Current.LocalStorage;
                List <Survey>        surveys = new List <Survey>();
                ExistenceCheckResult result  = await folder.CheckExistsAsync("ShareResponsedSurveys");

                if (result == ExistenceCheckResult.FolderExists)
                {
                    folder = await folder.CreateFolderAsync("ShareResponsedSurveys", CreationCollisionOption.OpenIfExists);

                    file = await folder.CreateFileAsync("ShareResponsedSurveys", CreationCollisionOption.OpenIfExists);

                    Content = await file.ReadAllTextAsync();

                    if (String.IsNullOrEmpty(Content) || String.IsNullOrWhiteSpace(Content))
                    {
                        return;
                    }
                    surveys = Serializable_Survey.deserialize(Content).ToList();
                    foreach (Survey S in surveys)
                    {
                        SurveysServices S_S = new SurveysServices();
                        S_S.Set_UrlApi("ShareResponsedSurveys/");
                        await S_S.PostSurveysAsync(S);
                    }
                    folder = FileSystem.Current.LocalStorage;
                    folder = await folder.GetFolderAsync("ShareResponsedSurveys");

                    await folder.DeleteAsync();
                }

                // Receive Surveys
                ReceiveSurveys();
                // Receive Responsed Surveys
                ReceiveResponsedSurveys();
            }
        }
        private async void GetSurveys()
        {
            string content;

            folder = FileSystem.Current.LocalStorage;
            if (CheckNetwork.Check_Connectivity())
            {
                ActivityIndicator.IsVisible    = true;
                ActivityIndicator.IsRunning    = true;
                contentpageEducation.IsVisible = false;

                SurveysServices S_S = new SurveysServices();
                S_S.Set_UrlApi("ReceiveSurveysShared/" + username);
                ReceivedSurveys = await S_S.GetSurveysAsync();

                ExistenceCheckResult result = await folder.CheckExistsAsync("Receivedsurveys");

                if (result == ExistenceCheckResult.FolderExists)
                {
                    folder = await folder.CreateFolderAsync("Receivedsurveys", CreationCollisionOption.OpenIfExists);

                    file = await folder.CreateFileAsync("Receivedsurveys", CreationCollisionOption.OpenIfExists);

                    content = await file.ReadAllTextAsync();

                    OldreceiveSurveys = Serializable_Survey.deserialize(content).ToList();
                    if (OldreceiveSurveys.Count < ReceivedSurveys.Count)
                    {
                        var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                        player.Load("NotificationReceive.mp3");
                        player.Play();

                        Plugin.LocalNotifications.CrossLocalNotifications.Current.Show(Lang.Resource.receivesurveys, Lang.Resource.BodyreceiveSurvey, 0);
                    }
                }
                else if (result != ExistenceCheckResult.FolderExists && ReceivedSurveys.Count > 0)
                {
                    var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                    player.Load("NotificationReceive.mp3");
                    player.Play();

                    Plugin.LocalNotifications.CrossLocalNotifications.Current.Show(Lang.Resource.receivesurveys, Lang.Resource.BodyreceiveSurvey, 0);
                }
            }
            else
            {
                ExistenceCheckResult Result = await folder.CheckExistsAsync("Receivedsurveys");

                if (Result == ExistenceCheckResult.FolderExists)
                {
                    ActivityIndicator.IsVisible    = true;
                    ActivityIndicator.IsRunning    = true;
                    contentpageEducation.IsVisible = false;

                    folder = await folder.CreateFolderAsync("Receivedsurveys", CreationCollisionOption.OpenIfExists);

                    file = await folder.CreateFileAsync("Receivedsurveys", CreationCollisionOption.OpenIfExists);

                    content = await file.ReadAllTextAsync();

                    ReceivedSurveys = Serializable_Survey.deserialize(content).ToList();

                    Full_Lists_Surveys();
                }
                else
                {
                    Full_Lists_Surveys();

                    ActivityIndicator.IsVisible = false;
                    ActivityIndicator.IsRunning = false;
                    await Task.Delay(200);

                    contentpageEducation.IsVisible = true;
                    return;
                }
            }
            if (ReceivedSurveys.Count == 0)
            {
                Full_Lists_Surveys();
                ActivityIndicator.IsVisible    = false;
                ActivityIndicator.IsRunning    = false;
                contentpageEducation.IsVisible = true;
                return;
            }
            else
            {
                folder = FileSystem.Current.LocalStorage;
                folder = await folder.CreateFolderAsync("Receivedsurveys", CreationCollisionOption.ReplaceExisting);

                file = await folder.CreateFileAsync("Receivedsurveys", CreationCollisionOption.ReplaceExisting);

                content = Serializable_Survey.serialize(ReceivedSurveys);
                await file.WriteAllTextAsync(content);

                Full_Lists_Surveys();

                await Task.Delay(700);

                ActivityIndicator.IsVisible = false;
                ActivityIndicator.IsRunning = false;
                await Task.Delay(200);

                contentpageEducation.IsVisible = true;
            }
        }
예제 #9
0
        private async void SaveData_Activated(object sender, EventArgs e)
        {
            if (!CheckNetwork.Check_Connectivity())
            {
                return;
            }
            string inputs = questionEntry.Text + minvalue.Text + maxvalue.Text;

            if (String.IsNullOrWhiteSpace(inputs) || inputs.Contains("~"))
            {
                checkinputs.Text = Lang.Resource.check_inputsSignin3;
                return;
            }
            Slider_Question question = new Slider_Question(TypeQuestion.Slider, questionEntry.Text);

            question.Create_question(Int32.Parse(minvalue.Text), Int32.Parse(maxvalue.Text), switchRequireAnswer.IsToggled);

            // Store Data in File Of Survey
            folder = FileSystem.Current.LocalStorage;

            username = await controlFile.GetUserName();

            folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.OpenIfExists);

            file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.OpenIfExists);

            string content = await file.ReadAllTextAsync();

            ListSurveys = Serializable_Survey.deserialize(content);
            if (_questionSelected != null)
            {
                foreach (Survey S in ListSurveys)
                {
                    if (S.Id == survey.Id)
                    {
                        Slider_Question slider = new Slider_Question(TypeQuestion.Slider, questionEntry.Text);

                        slider.title      = questionEntry.Text;
                        slider.requireAns = switchRequireAnswer.IsToggled;
                        slider.min_value  = Int32.Parse(minvalue.Text);
                        slider.max_value  = Int32.Parse(maxvalue.Text);
                        (S.Questions_Property.ElementAt(_index) as Slider_Question).Edit_question(slider);
                        survey = S;
                        break;
                    }
                }
            }
            else
            {
                foreach (Survey S in ListSurveys)
                {
                    if (S.Id == survey.Id)
                    {
                        S.Questions_Property.Add(question);

                        survey = S;
                        break;
                    }
                }
            }
            if (CheckNetwork.Check_Connectivity())
            {
                SurveysServices S_S = new SurveysServices();
                S_S.Set_UrlApi("EditSurveys/" + username);
                await S_S.PutSurveysAsync(survey);
            }


            content = Serializable_Survey.serialize(ListSurveys.ToList());

            await file.WriteAllTextAsync(content);

            await Navigation.PopModalAsync();
        }
예제 #10
0
        private async void Save_Survey(object sender, EventArgs e, TypeSurvey type)
        {
            string          content;
            List <Question> list = new List <Question>();

            folder = FileSystem.Current.LocalStorage;

            Survey survey = new Survey(list, username, title, description, (DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss")).Substring(0, DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss").Length - 8));

            survey.type_Property = type;
            ExistenceCheckResult Result = await folder.CheckExistsAsync("foldersurveys" + username);

            if (Result != ExistenceCheckResult.FolderExists)
            {
                folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.ReplaceExisting);
            }
            else
            {
                folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.OpenIfExists);
            }
            Result = await folder.CheckExistsAsync("filesurveys" + username);

            if (Result != ExistenceCheckResult.FileExists)
            {
                file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.ReplaceExisting);

                survey.Id = 1;
                ListSurveys.Add(survey);
                content = Serializable_Survey.serialize(ListSurveys);
                await file.WriteAllTextAsync(content);

                Full_Lists_Surveys();

                if (CheckNetwork.Check_Connectivity())
                {
                    SurveysServices S_S1 = new SurveysServices();
                    S_S1.Set_UrlApi("SaveSurveys/");
                    await S_S1.PostSurveysAsync(survey);
                }
                stackEducation.IsVisible = false;
                Cancel(sender, e);
                return;
            }
            file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.OpenIfExists);

            content = await file.ReadAllTextAsync();

            ListSurveys = Serializable_Survey.deserialize(content).ToList();
            if (ListSurveys.Count != 0)
            {
                survey.Id = ListSurveys[ListSurveys.Count - 1].Id + 1;
            }
            else
            {
                survey.Id = 1;
            }
            ListSurveys.Add(survey);
            content = Serializable_Survey.serialize(ListSurveys);
            await file.WriteAllTextAsync(content);

            Full_Lists_Surveys();

            if (CheckNetwork.Check_Connectivity())
            {
                SurveysServices S_S = new SurveysServices();
                S_S.Set_UrlApi("SaveSurveys/");
                await S_S.PostSurveysAsync(survey);
            }
            stackEducation.IsVisible = false;
            Cancel(sender, e);
        }
예제 #11
0
        private async void Get_Surveys()
        {
            try
            {
                ActivityIndicator.IsRunning    = true;
                contentpageEducation.IsVisible = false;

                folder = FileSystem.Current.LocalStorage;
                ExistenceCheckResult Resultfolder = await folder.CheckExistsAsync("folderUser");

                if (Resultfolder != ExistenceCheckResult.FolderExists)
                {
                    await Navigation.PushAsync(new Login());

                    return;
                }

                username = await controlFile.GetUserName();

                Resultfolder = await folder.CheckExistsAsync("foldersurveys" + username);

                if (Resultfolder != ExistenceCheckResult.FolderExists)
                {
                    if (!CheckNetwork.Check_Connectivity())
                    {
                        await Task.Delay(700);

                        ActivityIndicator.IsRunning    = false;
                        contentpageEducation.IsVisible = true;
                        return;
                    }
                    SurveysServices S_S1 = new SurveysServices();
                    S_S1.Set_UrlApi("ReceiveMySurveysSaved/" + username);
                    ListSurveys = await S_S1.GetSurveysAsync();

                    if (ListSurveys == null || ListSurveys.Count == 0)
                    {
                        await Task.Delay(700);

                        ActivityIndicator.IsRunning    = false;
                        contentpageEducation.IsVisible = true;
                        return;
                    }

                    folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.ReplaceExisting);

                    file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.ReplaceExisting);

                    string Content = Serializable_Survey.serialize(ListSurveys);
                    await file.WriteAllTextAsync(Content);

                    stackEducation.IsVisible = false;

                    Full_Lists_Surveys();

                    await Task.Delay(700);

                    ActivityIndicator.IsRunning    = false;
                    contentpageEducation.IsVisible = true;
                    return;
                }
                folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.OpenIfExists);

                file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.OpenIfExists);

                string content = await file.ReadAllTextAsync();

                ListSurveys = Serializable_Survey.deserialize(content).ToList();

                if (ListSurveys == null || ListSurveys.Count == 0)
                {
                    await Task.Delay(700);

                    ActivityIndicator.IsRunning    = false;
                    contentpageEducation.IsVisible = true;
                    return;
                }
                stackEducation.IsVisible = false;

                Full_Lists_Surveys();

                await Task.Delay(700);

                ActivityIndicator.IsRunning    = false;
                contentpageEducation.IsVisible = true;
            }
            catch (Exception ex)
            {
                ActivityIndicator.IsVisible = false;
                ActivityIndicator.IsRunning = false;
                DependencyService.Get <SnackBar>().ShowSnackBar("Error ... cann't access to device storage");
            }
        }
        private async void SaveData_Activated(object sender, EventArgs e)
        {
            int count = stackAnswerChoice.Children.Count;

            for (int i = 0; i < count; i++)
            {
                Grid  G = stackAnswerChoice.Children.ElementAt(i) as Grid;
                Entry E = G.Children.ElementAt(0) as Entry;
                if (String.IsNullOrWhiteSpace(E.Text))
                {
                    E.IsVisible = false;
                    continue;
                }
                if (E.IsVisible && E.Text.Contains("~"))
                {
                    checkinputs.Text = Lang.Resource.check_inputsSignin3;
                    return;
                }
                if (!String.IsNullOrWhiteSpace(E.Text) && G.IsVisible)
                {
                    entries.Add(E);
                }
            }
            List <string> choices = new List <string>();

            for (int i = 0; i < entries.Count; i++)
            {
                if (entries[i].IsVisible)
                {
                    choices.Add(entries[i].Text);
                }
            }
            if (switchOtherAnswer.IsToggled)
            {
                choices.Add("Other");
            }
            string[] answers = new string[choices.Count];
            for (int i = 0; i < choices.Count; i++)
            {
                answers[i] = choices[i];
            }
            Multible question = new Multible(TypeQuestion.DropDown, questionEntry.Text, answers.Length);

            question.require_Ans = switchRequireAnswer.IsToggled;
            question.Create_question(questionEntry.Text, answers);

            //// Store Data in File Of Survey
            folder   = FileSystem.Current.LocalStorage;
            username = await controlFile.GetUserName();

            folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.OpenIfExists);

            file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.OpenIfExists);

            string content = await file.ReadAllTextAsync();

            ListSurveys = Serializable_Survey.deserialize(content);

            if (_questionSelected != null)
            {
                foreach (Survey S in ListSurveys)
                {
                    if (S.Id == survey.Id)
                    {
                        (S.Questions_Property.ElementAt(_index) as Multible).Type        = TypeQuestion.DropDown;
                        (S.Questions_Property.ElementAt(_index) as Multible).require_Ans = switchRequireAnswer.IsToggled;
                        (S.Questions_Property.ElementAt(_index) as Multible).bound       = answers.Length;
                        (S.Questions_Property.ElementAt(_index) as Multible).Create_question(questionEntry.Text, answers);
                        survey = S;
                        break;
                    }
                }
            }
            else
            {
                foreach (Survey S in ListSurveys)
                {
                    if (S.Id == survey.Id)
                    {
                        S.Questions_Property.Add(question);

                        survey = S;
                        break;
                    }
                }
            }
            if (CheckNetwork.Check_Connectivity())
            {
                SurveysServices S_S = new SurveysServices();
                S_S.Set_UrlApi("EditSurveys/" + username);
                await S_S.PutSurveysAsync(survey);
            }

            content = Serializable_Survey.serialize(ListSurveys.ToList());
            await file.WriteAllTextAsync(content);

            await Navigation.PopModalAsync();
        }
예제 #13
0
        private async void Save_Activated(object sender, EventArgs e)
        {
            stackQuestions.BackgroundColor = Color.FromHex("e5e5e5");
            var res = await DisplayAlert(Lang.Resource.titleMessage, Lang.Resource.bodyMessageSave, Lang.Resource.btnCancelMessage, Lang.Resource.btnOkMessage);

            stackQuestions.BackgroundColor = Color.FromHex("ffffff");
            if (res)
            {
                return;
            }

            ActivityIndicator.IsRunning = true;
            stackQuestions.Opacity      = 0.4;

            folder = FileSystem.Current.LocalStorage;
            folder = await folder.CreateFolderAsync("folderUser", CreationCollisionOption.OpenIfExists);

            file = await folder.CreateFileAsync("fileUser", CreationCollisionOption.OpenIfExists);

            string AccountUser = await file.ReadAllTextAsync();

            User register = Serializable_Account.deserialize(AccountUser).ElementAt(0);

            for (int i = 1; i < stackQuestions.Children.Count; i++)
            {
                string date = "";
                // Get Answer From Text Question
                if (((stackQuestions.Children.ElementAt(i) as StackLayout).StyleId.Equals("text")))
                {
                    string answer = ((stackQuestions.Children.ElementAt(i) as StackLayout).Children[2] as Entry).Text;
                    if (String.IsNullOrWhiteSpace(answer) && (SelectedSurvey.Questions[i - 1] as Text_Question).requireAnswer)
                    {
                        DependencyService.Get <SnackBar>().ShowSnackBar(Lang.Resource.the_question + i + Lang.Resource.restTheQuestion);
                        return;
                    }
                    if (!String.IsNullOrWhiteSpace(answer))
                    {
                        if (answer.Contains("~"))
                        {
                            DependencyService.Get <SnackBar>().ShowSnackBar(Lang.Resource.the_question + i + Lang.Resource.rest_theTextQuestion);
                            return;
                        }
                    }
                    date += DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
                    (SelectedSurvey.Questions[i - 1] as Text_Question).Answer_question(answer, date, register);
                }
                else if (((stackQuestions.Children.ElementAt(i) as StackLayout).StyleId.Equals("dropdown")))
                {
                    string answer = ((stackQuestions.Children.ElementAt(i) as StackLayout).Children[2] as Picker).Title;
                    if ((String.IsNullOrWhiteSpace(answer) || answer.Equals("Choices")) && (SelectedSurvey.Questions[i - 1] as Multible).require_Ans)
                    {
                        DependencyService.Get <SnackBar>().ShowSnackBar(Lang.Resource.the_question + i + Lang.Resource.restTheQuestion);
                        return;
                    }
                    date += DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
                    (SelectedSurvey.Questions[i - 1] as Multible).Answer_question(answer, date, register);
                }
                else if (((stackQuestions.Children.ElementAt(i) as StackLayout).StyleId.Equals("multible")))
                {
                    bool answered = false;
                    if ((SelectedSurvey.Questions[i - 1] as Multible).Type.Equals(TypeQuestion.Multible))
                    {
                        string answer = "";
                        for (int j = 0; j < (((stackQuestions.Children[i] as StackLayout).Children[2] as StackLayout).Children[0] as StackLayout).Children.Count; j++)
                        {
                            var stack = (((stackQuestions.Children[i] as StackLayout).Children[2] as StackLayout).Children[0] as StackLayout).Children[j] as StackLayout;
                            var img   = stack.Children[0] as Image;
                            if (!img.StyleId.Contains("un"))
                            {
                                answer   = (((((stackQuestions.Children[i] as StackLayout).Children[2] as StackLayout).Children[0] as StackLayout).Children[j] as StackLayout).Children[1] as Label).Text;
                                answered = true;
                            }
                        }
                        if (!answered && (SelectedSurvey.Questions[i - 1] as Multible).require_Ans)
                        {
                            DependencyService.Get <SnackBar>().ShowSnackBar(Lang.Resource.the_question + i + Lang.Resource.restTheQuestion);
                            return;
                        }
                        Multiable_answer multiAnswer = new Multiable_answer((((stackQuestions.Children[i] as StackLayout).Children[2] as StackLayout).Children[0] as StackLayout).Children.Count);

                        date += DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
                        (SelectedSurvey.Questions[i - 1] as Multible).Answer_question(answer, date, register);
                    }
                    else if ((SelectedSurvey.Questions[i - 1] as Multible).Type.Equals(TypeQuestion.MultiChoice))
                    {
                        string[] multichoicesAnswers = new string[(((stackQuestions.Children[i] as StackLayout).Children[2] as StackLayout).Children[0] as StackLayout).Children.Count];
                        for (int j = 0; j < (((stackQuestions.Children[i] as StackLayout).Children[2] as StackLayout).Children[0] as StackLayout).Children.Count; j++)
                        {
                            var stack = (((stackQuestions.Children[i] as StackLayout).Children[2] as StackLayout).Children[0] as StackLayout).Children[j] as StackLayout;
                            var img   = stack.Children[0] as Image;
                            if (!img.StyleId.Contains("un"))
                            {
                                multichoicesAnswers[j] = (((((stackQuestions.Children[i] as StackLayout).Children[2] as StackLayout).Children[0] as StackLayout).Children[j] as StackLayout).Children[1] as Label).Text;
                                answered = true;
                            }
                        }
                        if (!answered && (SelectedSurvey.Questions[i - 1] as Multible).require_Ans)
                        {
                            DependencyService.Get <SnackBar>().ShowSnackBar(Lang.Resource.the_question + i + Lang.Resource.restTheQuestion);
                            return;
                        }
                        (SelectedSurvey.Questions[i - 1] as Multible).list_multichoice_answer = new LinkedList <MultiChoiceAnswercs>();
                        MultiChoiceAnswercs multichoices = new MultiChoiceAnswercs(multichoicesAnswers.Length);

                        date += DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
                        (SelectedSurvey.Questions[i - 1] as Multible).Answer_question(multichoicesAnswers, date, register);
                    }
                }
                else if (((stackQuestions.Children.ElementAt(i) as StackLayout).StyleId.Equals("slider")))
                {
                    int counter = (int)(((stackQuestions.Children[i] as StackLayout).Children[2] as StackLayout).Children[1] as Slider).Value;
                    date += DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
                    (SelectedSurvey.Questions[i - 1] as Slider_Question).Answer_question(counter, date, register);
                }
            }
            stackQuestions.Opacity = 0.5;
            if (CheckNetwork.Check_Connectivity())
            {
                SurveysServices S_S = new SurveysServices();
                S_S.Set_UrlApi("ShareResponsedSurveys/");
                await S_S.PostSurveysAsync(SelectedSurvey);
            }
            else
            {
                List <Survey> surveys = new List <Survey>();
                folder = FileSystem.Current.LocalStorage;
                ExistenceCheckResult result = await folder.CheckExistsAsync("ShareResponsedSurveys");

                if (result == ExistenceCheckResult.FolderExists)
                {
                    folder = await folder.CreateFolderAsync("ShareResponsedSurveys", CreationCollisionOption.OpenIfExists);

                    file = await folder.CreateFileAsync("ShareResponsedSurveys", CreationCollisionOption.OpenIfExists);

                    string Content = await file.ReadAllTextAsync();

                    if (String.IsNullOrEmpty(Content) || String.IsNullOrWhiteSpace(Content))
                    {
                        surveys.Add(SelectedSurvey);
                        Content = Serializable_Survey.serialize(surveys);
                        await file.WriteAllTextAsync(Content);

                        await Task.Delay(500);

                        await Navigation.PopAsync();

                        return;
                    }

                    surveys = Serializable_Survey.deserialize(Content).ToList();
                    if (surveys.Contains(SelectedSurvey))
                    {
                        foreach (Survey S in surveys)
                        {
                            if (S.Id == SelectedSurvey.Id_Property)
                            {
                                S.Questions = SelectedSurvey.Questions;
                            }
                        }
                    }
                    else
                    {
                        surveys.Add(SelectedSurvey);
                    }
                    Content = Serializable_Survey.serialize(surveys);
                    await file.WriteAllTextAsync(Content);
                }
                else
                {
                    folder = await folder.CreateFolderAsync("ShareResponsedSurveys", CreationCollisionOption.ReplaceExisting);

                    file = await folder.CreateFileAsync("ShareResponsedSurveys", CreationCollisionOption.ReplaceExisting);

                    surveys.Add(SelectedSurvey);
                    string content = Serializable_Survey.serialize(surveys);
                    await file.WriteAllTextAsync(content);
                }
            }
            await Task.Delay(500);

            await Navigation.PopAsync();
        }