public static async Task <bool> delete(CloudTable redirectTable, RedirectEntity entity) { await redirectTable.CreateIfNotExistsAsync(); try { TableOperation deleteOperation = TableOperation.Delete(entity); await redirectTable.ExecuteAsync(deleteOperation); } catch { return(false); } return(true); }
public static async Task <bool> put(CloudTable redirectTable, RedirectEntity entityToUpdate) { await redirectTable.CreateIfNotExistsAsync(); try { TableOperation redirectOperation = TableOperation.InsertOrMerge(entityToUpdate); await redirectTable.ExecuteAsync(redirectOperation); } catch { return(false); } return(true); }
public static async Task <bool> put(CloudTable redirectTable, string key, string redirectTo, string videoLink, int startRedirectingMinutes, int clickCount, int calendarClickCount, int videoClickCount, IDictionary <string, int> geoCount, IDictionary <string, int> calendarGeoCount, IDictionary <string, int> videoGeoCount) { await redirectTable.CreateIfNotExistsAsync(); try { RedirectEntity newEntity = new RedirectEntity(key, redirectTo, videoLink, startRedirectingMinutes, clickCount, calendarClickCount, videoClickCount, geoCount, calendarGeoCount, videoGeoCount); TableOperation redirectOperation = TableOperation.InsertOrMerge(newEntity); await redirectTable.ExecuteAsync(redirectOperation); } catch { return(false); } return(true); }
public static async Task <RedirectEntity> get(CloudTable redirectTable, string key) { await redirectTable.CreateIfNotExistsAsync(); TableQuery <RedirectEntity> rangeQuery = new TableQuery <RedirectEntity>().Where( TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, $"{key}")); var sessionRedirectFound = await redirectTable.ExecuteQuerySegmentedAsync(rangeQuery, null); if (sessionRedirectFound.Results.Count > 0) { RedirectEntity entity = sessionRedirectFound.Results.ToArray()[0]; return(entity); } else { return(null); } }