Esempio n. 1
0
        protected void PopulateAuditFieldsOnUpdate <T>(AuditableDto <T> dto)
        {
            var currentUtcTime = DateTime.UtcNow;

            dto.LastModifiedBy       = "User";
            dto.LastModifiedDateTime = currentUtcTime;
        }
Esempio n. 2
0
        public void Apply(OpenApiSchema schema, SchemaFilterContext context)
        {
            if (schema.Properties != null)
            {
                var auditableProperties =
                    new AuditableDto()
                    .GetType()
                    .GetProperties()
                    .Where(a => a.CanRead)
                    .Select(a => a.Name.ToLower());

                foreach (var p in schema.Properties)
                {
                    var property = p.Key.ToLower();
                    if (!auditableProperties.Contains(property))
                    {
                        continue;
                    }

                    p.Value.ReadOnly = true;
                }
            }
        }