Пример #1
0
        public async Task <bool> SaveRecord()
        {
            bool bOK = true;

            try
            {
                using (var db = new DbContextScores())
                {
                    db.Scores.Add(this);
                    await db.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Error($"SaveRecord exception, {ex.Message}");
                bOK = false;
            }
            return(bOK);
        }
Пример #2
0
        // delete all scores
        internal static async Task <bool> DeleteAllRecords()
        {
            bool bOK = true;

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