expressappframework-113689-event-planning-and-notifications-how-to-use-notifications-with-a-custom-business-class.md
This example demonstrates how to associate Notifications with a custom business class.
Assume you have the following MyTask business class.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;
namespace MySolution.Module.BusinessObjects;
[DefaultClassOptions]
public class MyTask : BaseObject {
public virtual string Subject { get; set; }
public virtual DateTime DueDate { get; set; }
}
// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;
namespace MySolution.Module.BusinessObjects;
[DefaultClassOptions]
public class MyTask : BaseObject {
public MyTask(Session session) : base(session) { }
public string Subject {
get {
return GetPropertyValue<string>(nameof(Subject));
}
set {
SetPropertyValue(nameof(Subject), value);
}
}
public DateTime DueDate {
get {
return GetPropertyValue<DateTime>(nameof(DueDate));
}
set {
SetPropertyValue(nameof(DueDate), value);
}
}
}
The goal is to use the functionality of the Notifications module to send a reminder to a user before the DueDate.
Implement the ISupportNotifications interface in the MyTask class.
Override the OnSaving method to initialize AlarmTime based on the RemindIn interval specified by a user.
Run the application and create a new overdue task in the past (the DueDate should be earlier than the current time). Specify a non-empty value for the RemindIn property that defines the time between the notification alert and the DueDate moment (an empty RemindIn value means that the alert is never displayed).
Save the task. The Notifications window should appear after the time span specified in the NotificationsOptionsBase.NotificationsRefreshInterval property or sooner.
See Also