public void AddProfile(BrewProfile profile) { var profileBytes = ProfileWriter.Write(profile); if(profileBytes == null) { return; } if (!ProfileExists(profile)) { _conn.Insert(new BrewDatabaseTable { ProfileId = profile.Id.ToString(), Profile = profileBytes }); } else { UpdateProfile(profile); } //backup of file _profileFile?.CopyAsync(_profileFolder, DATABSE_NAME, NameCollisionOption.ReplaceExisting); }
public void UpdateProfile(BrewProfile profile) { BrewDatabaseTable entry = _entries.FirstOrDefault(t => t.ProfileId == profile.Id.ToString()); if (entry != null) { entry.Profile = ProfileWriter.Write(profile); _conn.Update(entry); } }
public List<BrewProfile> GetProfiles() { TableQuery<BrewDatabaseTable> query = _conn.Table<BrewDatabaseTable>(); _entries = query.ToList(); var profiles = new List<BrewProfile>(); foreach(var entry in query) { var profile = ProfileWriter.Read(entry.Profile); if (profile != null) { profiles.Add(profile); } } return profiles; }