public void DeleteDocument() { Console.WriteLine("List of documents"); var documents = StorageInformationAboutLogic.documents; foreach (var document in documents) { Console.WriteLine(document.Name); } var dName = Console.ReadLine(); var doc = documents.FirstOrDefault(_doc => dName == _doc.Name); if (doc == null) { Console.WriteLine("This name is invalid!"); } else { int id = doc.Id; documents.Remove(doc); UpdateIdForList(documents, id); Cache.AddInformationAboutTheFiles(documents, FileMode.Truncate); } }
public void CreateDocument() //Создание нового документа { Console.Clear(); Console.WriteLine($"Old count List: {StorageInformationAboutLogic.documents.Count}"); //test var _document = new StorageInformationAboutLogic().InformationAboutComputerPrint .CreateDocumentForPrint(StorageInformationAboutLogic.documents.Count + 1); if (CheckingTheFileName(_document)) { StorageInformationAboutLogic.documents.Add(_document); // Запись документа в листинг Cache.AddToCache(_document); Cache.AddInformationAboutTheFiles (StorageInformationAboutLogic.documents, System.IO.FileMode.OpenOrCreate); } else { Console.WriteLine("A document with this name already exists!"); } Console.WriteLine($"New count List: {StorageInformationAboutLogic.documents.Count}"); //test //return StorageInformationAboutLogic.documents.FirstOrDefault // (doc => doc.Id == StorageInformationAboutLogic.documents.Count); // Создание документа для печати }