Ejemplo n.º 1
0
        public async Task <int> SaveReferringSite(MobileReferringSiteModel referringSiteModel, string repositoryUrl)
        {
            var databaseConnection = await GetDatabaseConnection <MobileReferringSitesDatabaseModel>().ConfigureAwait(false);

            var referringSitesDatabaseModel = MobileReferringSitesDatabaseModel.ToReferringSitesDatabaseModel(referringSiteModel, repositoryUrl);

            return(await databaseConnection.InsertOrReplaceAsync(referringSitesDatabaseModel).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        public async Task <List <MobileReferringSiteModel> > GetReferringSites(string repositoryUrl)
        {
            var databaseConnection = await GetDatabaseConnection <MobileReferringSitesDatabaseModel>().ConfigureAwait(false);

            var referringSitesDatabaseModelList = await databaseConnection.Table <MobileReferringSitesDatabaseModel>().Where(x => x.RepositoryUrl == repositoryUrl).ToListAsync().ConfigureAwait(false);

            return(referringSitesDatabaseModelList.Select(x => MobileReferringSitesDatabaseModel.ToReferringSitesModel(x)).ToList());
        }
Ejemplo n.º 3
0
        public async Task <MobileReferringSiteModel?> GetReferringSite(string repositoryUrl, Uri?referrerUri)
        {
            var databaseConnection = await GetDatabaseConnection <MobileReferringSitesDatabaseModel>().ConfigureAwait(false);

            var referringSitesDatabaseModelList = await databaseConnection.Table <MobileReferringSitesDatabaseModel>().Where(x => x.RepositoryUrl == repositoryUrl && x.ReferrerUri == referrerUri).ToListAsync().ConfigureAwait(false);

            var newestReferringSiteModel = referringSitesDatabaseModelList.OrderByDescending(x => x.DownloadedAt).FirstOrDefault();

            return(newestReferringSiteModel is null ? null : MobileReferringSitesDatabaseModel.ToReferringSitesModel(newestReferringSiteModel));
        }
Ejemplo n.º 4
0
            public static MobileReferringSiteModel ToReferringSitesModel(MobileReferringSitesDatabaseModel referringSitesDatabaseModel)
            {
                var referringSiteModel = new ReferringSiteModel(referringSitesDatabaseModel.TotalCount, referringSitesDatabaseModel.TotalUniqueCount, referringSitesDatabaseModel.Referrer, referringSitesDatabaseModel.DownloadedAt);

                try
                {
                    return(new MobileReferringSiteModel(referringSiteModel, string.IsNullOrWhiteSpace(referringSitesDatabaseModel.FavIconImageUrl) ? null : ImageSource.FromUri(new Uri(referringSitesDatabaseModel.FavIconImageUrl))));
                }
                catch (UriFormatException)
                {
                    return(new MobileReferringSiteModel(referringSiteModel, ImageSource.FromFile(referringSitesDatabaseModel.FavIconImageUrl)));
                }
            }
Ejemplo n.º 5
0
            public static MobileReferringSiteModel ToReferringSitesModel(MobileReferringSitesDatabaseModel referringSitesDatabaseModel)
            {
                var referringSiteModel = new ReferringSiteModel(referringSitesDatabaseModel.TotalCount, referringSitesDatabaseModel.TotalUniqueCount, referringSitesDatabaseModel.Referrer, referringSitesDatabaseModel.DownloadedAt);

                return(new MobileReferringSiteModel(referringSiteModel, referringSitesDatabaseModel.FavIconImageUrl is null ? null : ImageSource.FromUri(new Uri(referringSitesDatabaseModel.FavIconImageUrl))));
            }