Ejemplo n.º 1
0
        /* Writes given TextData to the database. */
        public void WriteText(string TextID, string TextData)
        {
            SharepadContext DatabaseContext = new SharepadContext();
            Text            UpdateText      = DatabaseContext.Text.Find(TextID);

            if (UpdateText is null)
            {
                throw new ArgumentException($"Text with ID '{TextID}' not found.");
            }
            UpdateText.TextData   = TextData;
            UpdateText.AccessTime = DateTime.Now;
            DatabaseContext.Update(UpdateText);
            DatabaseContext.SaveChanges();
        }
Ejemplo n.º 2
0
        /* Reads a database entry with given TextID. */
        public string ReadText(string TextID)
        {
            SharepadContext DatabaseContext = new SharepadContext();
            Text            OutText         = DatabaseContext.Text.Find(TextID);

            if (OutText is null)
            {
                throw new ArgumentException($"Text with ID '{TextID}' not found.");
            }
            /* Set the access time and update the database. */
            OutText.AccessTime = DateTime.Now;
            DatabaseContext.Update(OutText);
            DatabaseContext.SaveChanges();
            return(OutText.TextData);
        }