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; } }
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); }
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; }