Inheritance: BaseModel
Esempio n. 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);
        }
Esempio n. 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();
        }