Пример #1
0
        public bool IsValid(CommandInput input)
        {
            if (input.HasArgument("record"))
            {
                model = input["record"].FromJsonToObject <AuditRecordModel>();
                return(model != null);
            }
            AuditArea   auditArea   = AuditArea.Suite;
            AuditReason auditReason = AuditReason.Retrieved;
            bool        valid       = Enum.TryParse(input["a"], out auditArea) &&
                                      input.HasArgument("akey") &&
                                      input.HasArgument("m") &&
                                      Enum.TryParse(input["r"], out auditReason);

            if (valid)
            {
                model = new AuditRecordModel
                {
                    Area    = auditArea,
                    Key     = input["akey"],
                    Message = input["m"],
                    Reason  = auditReason
                };
            }

            return(valid);
        }
Пример #2
0
        public async Task Record(AuditType type, AuditArea area, string description, string user)
        {
            await Ctx.Audit.AddAsync(new Audit
            {
                User        = user,
                AuditArea   = area,
                AuditType   = type,
                DateTime    = DateTime.UtcNow,
                Description = description
            });

            await Ctx.SaveChangesAsync();
        }
Пример #3
0
        public async Task Record(AuditType type, AuditArea area, string description, string user)
        {
            using (var tran = await Ctx.Database.BeginTransactionAsync())
            {
                await Ctx.Audit.AddAsync(new Audit
                {
                    User        = user,
                    AuditArea   = area,
                    AuditType   = type,
                    DateTime    = DateTime.UtcNow,
                    Description = description
                });

                await Ctx.SaveChangesAsync();

                tran.Commit();
            }
        }
Пример #4
0
 public async Task Record(AuditType type, AuditArea area, string description)
 {
     await Record(type, area, description, string.Empty);
 }