|
||
The following example creates an account status.
private bool CreateAccountStatus() { // Create new account status object AccountStatusInfo newStatus = new AccountStatusInfo() { AccountStatusDisplayName = "My new status", AccountStatusName = "MyNewStatus", AccountStatusSiteID = CMSContext.CurrentSiteID };
// Save the account status AccountStatusInfoProvider.SetAccountStatusInfo(newStatus);
return true; } |
The following example gets and updates the account status created by the example above.
private bool GetAndUpdateAccountStatus() { // Get the account status AccountStatusInfo updateStatus = AccountStatusInfoProvider.GetAccountStatusInfo("MyNewStatus", CMSContext.CurrentSiteName); if (updateStatus != null) { // Update a property updateStatus.AccountStatusDisplayName = updateStatus.AccountStatusDisplayName.ToLower();
// Save the changes AccountStatusInfoProvider.SetAccountStatusInfo(updateStatus);
return true; }
return false; } |
The following example gets and bulk updates multiple account statuses specified by a WHERE condition.
private bool GetAndBulkUpdateAccountStatuses() { // Get the account status dataset string where = "AccountStatusName LIKE N'MyNewStatus%'"; InfoDataSet<AccountStatusInfo> statuses = AccountStatusInfoProvider.GetAccountStatuses(where, null);
if (!DataHelper.DataSourceIsEmpty(statuses)) { foreach (AccountStatusInfo accountStatus in statuses) { // Update a property accountStatus.AccountStatusDisplayName = accountStatus.AccountStatusDisplayName.ToUpper();
// Save the changes AccountStatusInfoProvider.SetAccountStatusInfo(accountStatus); }
return true; }
return false; } |
The following example deletes the account status created by the first example in this topic.
private bool DeleteAccountStatus() { // Get the account status AccountStatusInfo deleteStatus = AccountStatusInfoProvider.GetAccountStatusInfo("MyNewStatus", CMSContext.CurrentSiteName);
if (deleteStatus != null) { // Delete the account status AccountStatusInfoProvider.DeleteAccountStatusInfo(deleteStatus);
return true; }
return false; } |