public IActionResult Index() { int errorCount; using (var context = new WatchDogErrorContext()) { errorCount = context.WatchDogErrors.Count(); } ViewData["ErrorCount"] = errorCount; return(View()); }
public IActionResult WatchDogErrors() { int errorCount; List <WatchDogErrorModel> errorList = new List <WatchDogErrorModel>(); using (var context = new WatchDogErrorContext()) { errorCount = context.WatchDogErrors.Count(); errorList = context.WatchDogErrors.Where(e => e.Status == 50).ToList(); } ViewData["ErrorCount"] = errorCount; ViewData["ErrorList"] = errorList; return(View()); }
public async Task AddWatchDogErrorToDb(WatchDogErrorModel wdError) { if (wdError == null) { throw new ArgumentNullException(); } using (var context = new WatchDogErrorContext()) { context.WatchDogErrors.Add(wdError); context.SaveChanges(); await _hubContext.Clients.All.UpdateWatchDogErrors(context.WatchDogErrors.ToList()); } }
public async Task CheckSqlQueries(string query) { //Kantakysely if (String.IsNullOrEmpty(query)) { throw new ArgumentNullException(); } using (var context = new WatchDogErrorContext()) { var errors = context.WatchDogErrors.FromSql(query).ToList(); //lisää ehto WatchDogErrorModel wdError = new WatchDogErrorModel("CheckSqlQueries", $"Method returned 0 rows.", 50, DateTime.Now, query); WatchDogHandler watchDogHandler = new WatchDogHandler(_hubContext); await watchDogHandler.AddWatchDogErrorToDb(wdError); } }