Exemplo n.º 1
0
        // log message to database
        public async void LogToDbAsync(string text)
        {
            try
            {
                using (var db = new DbContextLogs())
                {
                    var log = new DebugLog();
                    log.Log = text;
                    await db.Logs.AddAsync(log);

                    await db.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                Log.Error(Defines.TAG, "LogToDbAsync exception, " + ex.Message);
            }
        }
Exemplo n.º 2
0
        internal async Task <bool> DeleteAllRecords()
        {
            bool bOK = true;

            try
            {
                using (var db = new DbContextLogs())
                {
                    foreach (var data in db.Logs)
                    {
                        db.Logs.Remove(data);
                    }
                    await db.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Error($"DeleteAllRecords exception, {ex.Message}");
                bOK = false;
            }
            return(bOK);
        }