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); }
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(); }
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(); } }
public async Task Record(AuditType type, AuditArea area, string description) { await Record(type, area, description, string.Empty); }