コード例 #1
0
        /// <summary>
        /// Add record to AuditTrail. Delete or Recover action on a Table
        /// </summary>
        /// <param name="recordId">RecordId which was modified</param>
        /// <param name="recordVersionNo">Record Version o</param>
        /// <param name="updatedBy">Modified By</param>
        /// <param name="operation">Delete or Recover operation</param>
        /// <returns>true if success, False if fail</returns>
        public bool Add(object recordId, int?recordVersionNo, object updatedBy, RecordOperationEnum operation)
        {
            if (operation != RecordOperationEnum.Delete && operation != RecordOperationEnum.Recover)
            {
                throw new InvalidOperationException("Invalid call to this method. This method shall be call for Delete and Recover operation only.");
            }

            CreateTableIfNotExist();

            AuditTrailKeyValue audit = new AuditTrailKeyValue
            {
                OperationType       = operation,
                RecordId            = recordId.ToString(),
                RecordVersionNo     = (recordVersionNo ?? 0) + 1,
                TableName           = entityTableInfo.Name,
                CreatedBy           = updatedBy,
                lstAuditTrailDetail = new List <IAuditTrailDetail>()
                {
                    new AuditTrailKeyValueDetail()
                    {
                        ColumnName = Config.ISACTIVE_COLUMN.Name,
                        ColumnType = (int)DbType.Boolean,
                        OldValue   = (operation == RecordOperationEnum.Delete).ToString(),
                        NewValue   = (!(operation == RecordOperationEnum.Delete)).ToString()
                    }
                }
            };

            return(AddAuditTrail(audit));
        }
コード例 #2
0
        bool AddAuditTrail(AuditTrailKeyValue audit)
        {
            audit.AuditTrailId = (long)Add(audit);

            audit.lstAuditTrailDetail.ForEach(p => p.AuditTrailId = audit.AuditTrailId);
            //add child records in detail table
            if (audit.lstAuditTrailDetail != null)
            {
                foreach (AuditTrailKeyValueDetail detail in audit.lstAuditTrailDetail)
                {
                    detail.AuditTrailDetailId = (long)detailRepo.Add(detail);
                }
            }

            return(true);
        }