Пример #1
0
 /// <summary>
 /// Constructor of audit log entity.
 /// </summary>
 /// <param name="eventName">Name of the started event</param>
 /// <param name="user">UserAuditCRUD entity</param>
 /// <param name="action">Action taken</param>
 /// <param name="location">Local where the action took place</param>
 /// <param name="ipAddress">Which device performed the action</param>
 /// <param name="reason">For what reason</param>
 /// <param name="currentEntity">Current or updated entity</param>
 /// <param name="oldEntity">Entity before performing the action</param>
 public AuditLog(string eventName, UserAuditCRUD user, string action, string location, string ipAddress, string reason, object currentEntity, object oldEntity)
 {
     this.Timestamp     = DateTime.Now;
     this.EventName     = eventName;
     this.User          = user;
     this.Action        = action;
     this.Location      = location;
     this.IpAddress     = ipAddress;
     this.Reason        = reason;
     this.CurrentEntity = JsonConvert.SerializeObject(currentEntity);
     this.OldEntity     = JsonConvert.SerializeObject(oldEntity);
 }
Пример #2
0
        public async Task <Result <Exception, Unit> > ActionDelete(string eventName, UserAuditCRUD user, string location, string ipAddress, object oldEntity, string reason = "not informed")
        {
            var auditLog = new AuditLog(eventName: eventName,
                                        user: user,
                                        action: Actions.Delete,
                                        location: location,
                                        ipAddress: ipAddress,
                                        reason: reason,
                                        currentEntity: null,
                                        oldEntity: oldEntity);

            var auditLogAddedCallback = await PersistLogInDB(auditLog);

            if (auditLogAddedCallback.IsFailure)
            {
                return(auditLogAddedCallback.Failure);
            }

            return(Unit.Successful);
        }