コード例 #1
0
 public void Upsert()
 {
     try
     {
         RepositoryCore.Logger.Log(nameof(Setting.Upsert), ToString());
         using (var db = new SQLiteConnection(DBConnectionString.PLATFORM, DBConnectionString.DBPATH))
         {
             if (Id == -1)
             {
                 Id = 1;
                 db.Insert(this);
             }
             else
             {
                 db.Update(this);
             }
         }
         RepositoryCore.SetCurrentMonth(CurrentYear, CurrentMonth);
     }
     catch (Exception ex)
     {
         RepositoryCore.Logger.Log(nameof(Setting.Upsert), ex.Message, LogType.Exception);
         throw ex;
     }
 }
コード例 #2
0
        public void DbSetup()
        {
            if (File.Exists(_dbPath))
            {
                File.Delete(_dbPath);
            }

            var db = new SQLiteConnection(new SQLitePlatformIOS(), _dbPath);

            db.CreateTable <Category>();
            db.CreateTable <Expense>();
            db.CreateTable <Setting>();

            RepositoryCore.SetCurrentMonth(DateTime.Now.Year, DateTime.Now.Month);
        }
コード例 #3
0
        public void DbSetup()
        {
            if (File.Exists(_dbPath))
            {
                File.Delete(_dbPath);
            }

            var db = new SQLiteConnection(new SQLitePlatformIOS(), _dbPath);

            db.CreateTable <Category>();
            db.CreateTable <Expense>();
            db.CreateTable <Setting>();

            RepositoryCore.SetCurrentMonth(DateTime.Now.Year, DateTime.Now.Month);

            var category = new Category()
            {
                Name = "category",
                Plan = 20
            };

            category.Upsert();
            _categoryId = category.Id;
        }