Exemplo n.º 1
0
        public async Task <ShortUrlEntity> ArchiveShortUrlEntity(ShortUrlEntity urlEntity)
        {
            ShortUrlEntity originalUrl = await GetShortUrlEntity(urlEntity);

            originalUrl.IsArchived = true;

            return(await SaveShortUrlEntity(originalUrl));
        }
Exemplo n.º 2
0
        public async Task <ShortUrlEntity> GetShortUrlEntity(ShortUrlEntity row)
        {
            TableOperation selOperation = TableOperation.Retrieve <ShortUrlEntity>(row.PartitionKey, row.RowKey);
            TableResult    result       = await GetUrlsTable().ExecuteAsync(selOperation);

            ShortUrlEntity eShortUrl = result.Result as ShortUrlEntity;

            return(eShortUrl);
        }
Exemplo n.º 3
0
        public async Task <ShortUrlEntity> SaveShortUrlEntity(ShortUrlEntity newShortUrl)
        {
            TableOperation insOperation = TableOperation.InsertOrMerge(newShortUrl);
            TableResult    result       = await GetUrlsTable().ExecuteAsync(insOperation);

            ShortUrlEntity eShortUrl = result.Result as ShortUrlEntity;

            return(eShortUrl);
        }
        public async Task <ShortUrlEntity> UpdateShortUrlEntity(ShortUrlEntity urlEntity)
        {
            ShortUrlEntity originalUrl = await GetShortUrlEntity(urlEntity);

            originalUrl.Url   = urlEntity.Url;
            originalUrl.Title = urlEntity.Title;

            return(await SaveShortUrlEntity(originalUrl));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns the ShortUrlEntity of the <paramref name="vanity"/>
        /// </summary>
        /// <param name="vanity"></param>
        /// <returns>ShortUrlEntity</returns>
        public async Task <ShortUrlEntity> GetShortUrlEntityByVanity(string vanity)
        {
            var tblUrls = GetUrlsTable();
            TableContinuationToken token          = null;
            ShortUrlEntity         shortUrlEntity = null;

            do
            {
                TableQuery <ShortUrlEntity> query = new TableQuery <ShortUrlEntity>().Where(
                    filter: TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, vanity));
                var queryResult = await tblUrls.ExecuteQuerySegmentedAsync(query, token);

                shortUrlEntity = queryResult.Results.FirstOrDefault();
            } while (token != null);

            return(shortUrlEntity);
        }
Exemplo n.º 6
0
        public async Task <bool> IfShortUrlEntityExist(ShortUrlEntity row)
        {
            ShortUrlEntity eShortUrl = await GetShortUrlEntity(row);

            return(eShortUrl != null);
        }
Exemplo n.º 7
0
        public async Task <bool> IfShortUrlEntityExistByVanity(string vanity)
        {
            ShortUrlEntity shortUrlEntity = await GetShortUrlEntityByVanity(vanity);

            return(shortUrlEntity != null);
        }