public void AddTableRead() { loggingService.AddTableToLogger("conn1", "tbl1", HttpMethodType.GET); loggingService.LogAll().Wait(); using (var db = new LogDbContext(LogDbOptions)) { Assert.AreEqual(1, db.RequestLogs.Count()); Assert.AreEqual(1, db.ResponseLogs.Count()); //Check details Assert.AreEqual("conn1", db.RequestLogs.First().Connector); Assert.AreEqual("GET", db.RequestLogs.First().RequestType); Assert.AreEqual(new DateTime(2020, 1, 1), db.RequestLogs.First().DateTimeUtc); //Check linked Assert.AreEqual(db.RequestLogs.First().RequestGuid, db.ResponseLogs.First().RequestGuid); Assert.AreEqual(db.RequestLogs.First().RequestId, db.ResponseLogs.First().ResponseId); } }
/// <summary> /// Add or Update a connector. /// </summary> /// <returns>Redirect to edit page or display errors.</returns> public virtual IMiddlewareDispatcher Save() { _repo.Validate(model, errors); if (errors.Count == 0) { Guid id; if (model.Id == null) { LoggingService.AddTableToLogger(DefaultConnectors.AppDB, DefaultTables.Connectors, HttpMethodType.POST); id = _repo.Insert(model); } else { LoggingService.AddTableToLogger(DefaultConnectors.AppDB, DefaultTables.Connectors, HttpMethodType.PUT); id = _repo.Save(model); } return(new RedirectDispatcher($"/Connectors/Connector/{id}")); } ViewBag["resourceTypes"] = _repo.ListResoureTypes(); ViewBag["model"] = model; return(new RazorPageDispatcher(this)); }