コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }