//This entire method is awful and needs a rewrite.
        public async Task <Game> AddOrUpdateGame(Game g)
        {
            SQLite.SQLiteAsyncConnection db = await GetDatabaseConnection <Game>().ConfigureAwait(false);

            Game existing = null;

            if (g != null)
            {
                existing = await AttemptAndRetry(() => db.FindWithChildrenAsync <Game>(g.Id)).ConfigureAwait(false);
            }

            if (existing != null)
            {
                //full comparison of which values are needing updating, as not all "API" results return a full object
                //game ID and name should always be present though.
                if (existing.UserRating == 0)
                {
                    existing.UserRating = g.UserRating;
                }
                else
                {
                    g.UserRating = existing.UserRating;
                }

                if (g.GameStatus != Status.Nothing)
                {
                    existing.GameStatus = g.GameStatus;
                }

                if (g.InCollection)
                {
                    existing.InCollection = true;
                }

                //test to see if its just from  browse page
                if (string.IsNullOrEmpty(g.Description))
                {
                    existing.Thumbnail = g.Thumbnail;
                }

                if (existing.YearPublished != 0)
                {
                    g.YearPublished = existing.YearPublished;
                }
                else if (g.YearPublished != 0)
                {
                    existing.YearPublished = g.YearPublished;
                }

                if (existing.Ranks == null)
                {
                    existing.Ranks = new List <Ranking>();
                }

                if (g.Ranks == null)
                {
                    g.Ranks = existing.Ranks;
                }
                else
                {
                    foreach (var r in g.Ranks)
                    {
                        if (!existing.Ranks.Where(e => e.Category == r.Category).Any())
                        {
                            existing.Ranks.Add(r);
                        }
                    }
                }

                var merged = existing.MergeWith(g);

                await AttemptAndRetryNoResult <Game>(() => db.InsertOrReplaceWithChildrenAsync(merged)).ConfigureAwait(false);

                return(merged);
            }
            else
            {
                await AttemptAndRetryNoResult <Game>(() => db.InsertOrReplaceWithChildrenAsync(g)).ConfigureAwait(false);

                return(g);
            }
        }