/*
         *  METHOD      : AuditEntry
         *  DESCRIPTION :
         *      This method begins an entry into the audit table starting from inactivity
         *  PARAMETERS  :
         *      int userId    : logged in user's ID
         *      int PostID     : ID of post being created
         *      string action : create/modify/delete
         *  RETURNS     :
         *      Audit auditEntry.ID : the ID integer of the entry being recorded
         */
        public static int AuditEntry(int userId, int PostID, string action)
        {
            using (var context = new BookstoreContext())
            {
                var auditEntry = new Audits
                {
                    ActionTime = DateTime.Now,
                    User_ID = userId,
                    Posting_ID = PostID,
                    Action = action,

                };
                context.Audit.Add(auditEntry);
                context.SaveChanges();
                SaveDBcontext(context);
                return auditEntry.ID;
            }
        }
        /*
         *  METHOD      : AuditEntry
         *  DESCRIPTION :
         *      The end of the audit entry, add it into the audit table.
         *  PARAMETERS  :
         *      int userId        : user logged in
         *      int PostID         : Post ID (Post modified)
         *      string action     : one of static private strings above, denoting which action performed
         *      string attr       : attribute that was changed
         *      string oldValue   : attribute's old value
         *      string newValue   : attribute's new value
         *  RETURNS     :
         *      int auditEntry.ID : The new audit entry's traceable ID
         */
        public static int AuditEntry(int userId, int PostID, string action, string attr, string oldValue, string newValue)
        {
            using (var context = new BookstoreContext())
            {

                var auditEntry = new Audits
                {
                    ActionTime = DateTime.Now,
                    User_ID = userId,
                    Posting_ID = PostID,
                    Action = action,
                    Attribute_Name = attr,
                    Old_value = oldValue,
                    New_Value = newValue
                };

                context.Audit.Add(auditEntry);
                context.SaveChanges();

                return auditEntry.ID;
            }
        }