internal Document Save(Document Document) { var Documents = this.Retrieve(); var maxId = Documents.Max(c => c.DocumentId); Document.DocumentId = maxId + 1; Documents.Add(Document); //Update the json file WriteData(Documents); return Document; }
internal Document Save(int id, Document Document) { var Documents = this.Retrieve(); var itemIndex = Documents.FindIndex(c => c.DocumentId == Document.DocumentId); if (itemIndex > 0) { Documents[itemIndex] = Document; } else { return null; } //Update the json file WriteData(Documents); return Document; }