public static void ChangeViewedStatus(string key) { var statusMessage = String.Empty; try { var account = CloudStorageAccount.FromConfigurationSetting("TableDataConnectionString"); var context = new MessageDataServiceContext(account.TableEndpoint.ToString(), account.Credentials); var o = (from message in context.Messages where message.RowKey == key select message).First(); o.IsViewed = true; context.UpdateObject(o); context.SaveChanges(); } catch (DataServiceRequestException ex) { statusMessage = "Unable to connect to the table storage server. Please check that the service is running.<br>" + ex.Message; } }
public static void DeleteArticle(int AnnouncementID) { var statusMessage = String.Empty; try { var account = CloudStorageAccount.FromConfigurationSetting("TableDataConnectionString"); var context = new MessageDataServiceContext(account.TableEndpoint.ToString(), account.Credentials); while (true) { var o = (from message in context.Messages where message.IsNotification == false && message.AnnouncementID == AnnouncementID select message).FirstOrDefault(); if (o == null) return; context.DeleteObject(o); context.SaveChanges(); } } catch (DataServiceRequestException ex) { statusMessage = "Unable to connect to the table storage server. Please check that the service is running.<br>" + ex.Message; } }