public void delete() { var entries = _repo.read_entries(_parser.DirPath); if (entries == null) { _Console.WriteLine("No Entries found."); _Console.ReadLine(); return; } if (entries.Count == 0) { _Console.Clear(); _Console.WriteLine("No Entries... (Any Key to continue)"); _Console.ReadLine(); return; } compare(entries); _Console.Write("What is the name of the entry you want to delete? "); var name = _Console.ReadLine(); var item = entries.Find(x => x.SortWord == name); if (item.SortWord == null) { _Console.WriteLine("No entry found."); _Console.ReadLine(); return; } _Console.Write("Entry " + item.SortWord + " found, wish to delete it? y/N: "); var inp = _Console.ReadLine(); if (inp.ToUpper() == "Y") { DeviceNoteService.delete_entry(_parser.DirPath, item); _Console.WriteLine("Want also to exclude the sorted data & delete the created directory for the entry? Y/n: "); inp = _Console.ReadLine(); if (inp.ToUpper() == "N") { return; } else { DeviceNoteService.exclude_directory_delete(_parser.DirPath, item.SortWord); } } else { return; } }
public void compare(List <DeviceUserEntry> entries) { string[] paths = Directory.GetDirectories(_parser.DirPath); foreach (var entry in entries) { bool found = false; foreach (var p in paths) { var info = new DirectoryInfo(p).Name; if (entry.SortWord == info) { found = true; } } if (found == false) { DeviceNoteService.delete_entry(_parser.DirPath, entry); } } }