/// <summary> /// Get By Id /// </summary> /// <param name="id">Id</param> /// <returns>Person</returns> public Models.Person GetById(int id) { Models.Person model = null; using (var db = new SQLiteConnection(this.PathToSQLLiteDBFile)) { try { model = db.Get <Models.Person>(id); } catch { model = null; } } return(model); }
/// <summary> /// Add/Update a person /// </summary> /// <param name="model">Person</param> /// <returns>PK Id</returns> public int AddUpdate(Models.Person model) { int id = model.Id; if (model == null) { throw new ArgumentNullException("AddUpdate: Model can not be null"); } using (var db = new SQLiteConnection(this.PathToSQLLiteDBFile)) { if (id > 0) { var result = db.Update(model); } else { id = db.Insert(model); } } return(id); }