Inheritance: BaseModel
示例#1
0
        public virtual void Log(LoggableEntity entity)
        {
            AuditLog log = new AuditLog();
            log.AccountId = AccountId ?? HttpContext.Current.User.Identity.Name;
            log.AccountId = !String.IsNullOrEmpty(log.AccountId) ? log.AccountId : null;
            log.Changes = entity.ToString();
            log.EntityName = entity.Name;
            log.Action = entity.Action;
            log.EntityId = entity.Id;

            Context.Set<AuditLog>().Add(log);
        }
示例#2
0
        public void Save()
        {
            Int32? accountId = AccountId ?? HttpContext.Current.User.Id();
            foreach (LoggableEntity entity in Entities)
            {
                AuditLog log = new AuditLog();
                log.Changes = entity.ToString();
                log.EntityName = entity.Name;
                log.Action = entity.Action;
                log.EntityId = entity.Id();
                log.AccountId = accountId;

                Context.Set<AuditLog>().Add(log);
            }

            Context.SaveChanges();
            Entities.Clear();
        }