示例#1
0
        /// <summary>
        /// Deletes single survey from IsolatedStorage.
        /// </summary>
        /// <param name="surveyId">Id of survey you want to delete.</param>
        public void Delete(string surveyId)
        {
            Read();
            IEnumerable <SurveyBasicInfo> surveys;

            surveys = from SurveyBasicInfo in _list where SurveyBasicInfo.SurveyId == surveyId select SurveyBasicInfo;
            try
            {
                OperationsOnListOfResults resultsOperations = new OperationsOnListOfResults(surveyId);
                resultsOperations.DeleteAllResults();
                SurveyBasicInfo survey = surveys.First <SurveyBasicInfo>();
                using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    string filePath         = System.IO.Path.Combine("surveys", string.Format("{0}.xml", survey.SurveyId));
                    string directoryPath    = System.IO.Path.Combine("surveys", survey.SurveyId);
                    string listOfResultPath = System.IO.Path.Combine(directoryPath, "listOfResults.xml");
                    try
                    {
                        isoStore.DeleteFile(filePath);
                        isoStore.DeleteFile(listOfResultPath);
                        isoStore.DeleteDirectory(directoryPath);
                    }
                    catch (IsolatedStorageException) { /*that means that this files doesn't exists*/ }
                }
                _list.Remove(survey);
                Write();
            }
            catch (InvalidOperationException) { }
        }
示例#2
0
 /// <summary>
 /// Initializes all necessary data objects.
 /// </summary>
 public SurveyFilter()
 {
     AllSurveysItem = new SurveyBasicInfo()
     {
         Name = Languages.AppResources.resultsFilter_AllSurveys, SurveyId = "0"
     };
     ListPickerSurveys = new ObservableCollection <string>();
     SelectedSurveys   = new ObservableCollection <SurveyBasicInfo>();
     SelectedSurveys.Add(AllSurveysItem);
 }
示例#3
0
 /// <summary>
 /// Removes marked survey from list you want to search by.
 /// </summary>
 /// <param name="item"></param>
 public void RemoveSelectedSurvey(SurveyBasicInfo item)
 {
     if (item.SurveyId != "0")
     {
         SelectedSurveys.Remove(item);
     }
     if (SelectedSurveys.Count == 0)
     {
         SelectedSurveys.Add(AllSurveysItem);
     }
 }
示例#4
0
        private void ChangeFavorite(string surveyId, bool addSurvey)
        {
            Read();
            IEnumerable <SurveyBasicInfo> surveys;

            surveys = from SurveyBasicInfo in _list where SurveyBasicInfo.SurveyId == surveyId select SurveyBasicInfo;
            try
            {
                SurveyBasicInfo survey = surveys.First <SurveyBasicInfo>();
                int             index  = _list.IndexOf(survey);
                _list.Remove(survey);
                survey.IsFavorite = addSurvey;
                _list.Insert(index, survey);
                Write();
            }
            catch (InvalidOperationException)
            {
            }
        }
示例#5
0
        /// <summary>
        /// Adds selected survey to list you want to search by.
        /// </summary>
        /// <param name="avaiableSurveys">List of surveys currently saved in IsolatedStorage.</param>
        public void AddChosenSurvey(ObservableCollection <SurveyBasicInfo> avaiableSurveys)
        {
            int selectedIndex = Convert.ToInt32(ChosenSurvey);

            if (selectedIndex != avaiableSurveys.Count)
            {
                SurveyBasicInfo selectedItem = avaiableSurveys[selectedIndex];
                if (!SelectedSurveys.Contains(selectedItem))
                {
                    SelectedSurveys.Add(selectedItem);
                }
                if (SelectedSurveys.Count > 1)
                {
                    SelectedSurveys.Remove(AllSurveysItem);
                }
            }
            else
            {
                SelectedSurveys.Clear();
                SelectedSurveys.Add(AllSurveysItem);
            }
        }