public string AddOrUpdate(Notification notification)
{
string key = string.Empty;
var existingNotification = GetByRowKey(notification.RowKey);
if (existingNotification == null)
{
key = Guid.NewGuid().ToString();
notification.RowKey = key;
notification.Password = TickerEncryption.Utility.Encrypt(notification.Password, CloudConfigurationManager.GetSetting(Constants.Thumbprint1), CloudConfigurationManager.GetSetting(Constants.Thumbprint2));
notification.BalanceString = "New";
notification.LastVerification = DateTime.UtcNow;
context.AddObject(tableName, notification);
}
else
{
existingNotification.UserName = notification.UserName;
existingNotification.Password = TickerEncryption.Utility.Encrypt(notification.Password, CloudConfigurationManager.GetSetting(Constants.Thumbprint1), CloudConfigurationManager.GetSetting(Constants.Thumbprint2));
existingNotification.NotificationUri = notification.NotificationUri;
notification.LastVerification = DateTime.UtcNow;
key = existingNotification.RowKey;
context.UpdateObject(existingNotification);
}
return key;
}