|
||
|
API examples for newer versions Please visit the latest API Examples documentation to view API examples for newer versions of Kentico. |
The following example creates an abuse report.
private bool CreateAbuseReport() { // Create new abuse report object AbuseReportInfo newReport = new AbuseReportInfo();
// Set the properties newReport.ReportTitle = "MyNewReport"; newReport.ReportComment = "This is an example abuse report.";
newReport.ReportURL = URLHelper.GetAbsoluteUrl(URLHelper.CurrentURL); newReport.ReportCulture = CMSContext.PreferredCultureCode; newReport.ReportSiteID = CMSContext.CurrentSiteID; newReport.ReportUserID = CMSContext.CurrentUser.UserID; newReport.ReportWhen = DateTime.Now; newReport.ReportStatus = AbuseReportStatusEnum.New;
// Save the abuse report AbuseReportInfoProvider.SetAbuseReportInfo(newReport);
return true; } |
The following example gets and updates the abuse report created by the code example above.
private bool GetAndUpdateAbuseReport() { string where = "ReportTitle LIKE N'MyNewReport%'";
// Get the report DataSet reports = AbuseReportInfoProvider.GetAbuseReports(where, null);
if (!DataHelper.DataSourceIsEmpty(reports)) { // Create the object from DataRow AbuseReportInfo updateReport = new AbuseReportInfo(reports.Tables[0].Rows[0]);
// Update the properties updateReport.ReportStatus = AbuseReportStatusEnum.Solved;
// Save the changes AbuseReportInfoProvider.SetAbuseReportInfo(updateReport);
return true; }
return false; } |
The following example gets and bulk updates multiple abuse reports selected from database based on a WHERE condition.
private bool GetAndBulkUpdateAbuseReports() { // Prepare the parameters string where = "ReportTitle LIKE N'MyNewReport%'";
// Get the data DataSet reports = AbuseReportInfoProvider.GetAbuseReports(where, null); if (!DataHelper.DataSourceIsEmpty(reports)) { // Loop through the individual items foreach (DataRow reportDr in reports.Tables[0].Rows) { // Create object from DataRow AbuseReportInfo modifyReport = new AbuseReportInfo(reportDr);
// Update the properties modifyReport.ReportStatus = AbuseReportStatusEnum.Rejected;
// Save the changes AbuseReportInfoProvider.SetAbuseReportInfo(modifyReport); }
return true; }
return false; } |
The following example deletes the abuse report created by the first code example on this page.
private bool DeleteAbuseReport() { string where = "ReportTitle LIKE N'MyNewReport%'";
// Get the report DataSet reports = AbuseReportInfoProvider.GetAbuseReports(where, null);
if (!DataHelper.DataSourceIsEmpty(reports)) { // Create the object from DataRow AbuseReportInfo deleteReport = new AbuseReportInfo(reports.Tables[0].Rows[0]);
// Delete the abuse report AbuseReportInfoProvider.DeleteAbuseReportInfo(deleteReport);
return true; }
return false; } |