示例#1
0
        public static void SeedDatabase(AuditLogDbContext context)
        {
            var customers = new List <Customer>
            {
                new Customer
                {
                    FirstName = "Test1",
                    LastName  = "Test1",
                    Salary    = 10000
                },
                new Customer
                {
                    FirstName = "Test2",
                    LastName  = "Test2",
                    Salary    = 20000
                }
            };

            context.Database.Migrate();

            //return customers;
            if (!context.Customers.Any())
            {
                context.Customers.AddRange(customers);
                context.SaveChanges();
            }
        }
示例#2
0
        public void CreateLog(int entityId, string entityType, int operationTypeId, Object oldRecord, Object newRecord)
        {
            AuditLog auditLog = new AuditLog();

            auditLog.EntityId         = entityId;
            auditLog.EntityType       = entityType;
            auditLog.OperationTypeId  = operationTypeId;
            auditLog.LoggedInUserName = "******";
            auditLog.Timestamp        = DateTime.Now;
            var changes = CompareObjects(oldRecord, newRecord);

            auditLog.Changes    = changes;
            auditLog.ChangeLogs = JsonConvert.SerializeObject(changes);
            _auditLogDbContext.AuditLogs.Add(auditLog);
            _auditLogDbContext.SaveChanges();
        }
示例#3
0
 public void CreateCustomer(Customer customer)
 {
     _auditLogDbContext.Add(customer);
     _auditLogDbContext.SaveChanges();
     _auditLogRepository.CreateLog(customer.Id, "Customer", Convert.ToInt16(OperationTypeEnum.Create), new Customer(), customer);
 }