Beispiel #1
0
        private void RemoveAllRecent()
        {
            var removals = AllQueries.Where(x => x.Model.QueryType == QueryTypeOption.Recent).ToList();

            foreach (var removal in removals)
            {
                AllQueries.Remove(removal);
            }
            RefreshQueries();
        }
Beispiel #2
0
        protected override bool SaveData()
        {
            if (model != null)
            {
                model.Items.CleansePaths();
                var removals = model.Items.Where(x => x.IsRemove).ToList();
                if (removals.Count > 0)
                {
                    string directory = Path.Combine(AppConstants.ContentDirectory, AppConstants.ContentFiles);
                    foreach (var removal in removals)
                    {
                        if (!removal.Mime.Equals("text") &&
                            !String.IsNullOrWhiteSpace(removal.Mime) &&
                            !removal.Mime.Equals("url") &&
                            !removal.Mime.Equals("text/credential"))
                        {
                            string filepath = System.IO.Path.Combine(directory, removal.Body);
                            if (System.IO.File.Exists(filepath))
                            {
                                System.IO.File.Delete(filepath);
                            }
                        }
                        model.Items.Remove(removal);
                    }
                }
                List <QueryTypeOption> exclusions = new List <QueryTypeOption>()
                {
                    QueryTypeOption.None, QueryTypeOption.Recent
                };
                model.Queries = AllQueries.Where(x => !exclusions.Contains(x.Model.QueryType)).Select(x => x.Model).ToList().Cleanse();

                if (!DataService.TryWrite <Content>(model, out string message, Filepath()))
                {
                    OnFailure(message);
                    return(false);
                }
            }
            return(true);
        }