using System.Threading.Tasks;
using Kreta.Core.MessageBroker.Contract.MobileNotification;
using Kreta.Core.MessageBroker.Contract.MobileNotification.Enum;
namespace Kreta.MessageBroker.Client.MobileNotification
{
///
/// Mobile notification message helper
///
public class MobileNotificationMessageHelper
{
#region [Public Methods]
///
/// Create
///
/// Institute code
/// Institute user id
/// Item id
/// Message
/// Notification type
public static MobileNotificationMessage CreateMessage(string instituteCode, int instituteUserId, MobileNotificationMessageType notificationType, int itemId, string message)
{
return new MobileNotificationMessage(instituteCode, instituteUserId, MobileNotificationMessageRole.Student | MobileNotificationMessageRole.Tutelary, notificationType, MobileNotificationMessageSource.Kreta, MobileNotificationMessageDestination.RoleGroup, itemId, message);
}
///
/// Create
///
/// Institute code
/// Institute user id
/// Notification type
/// Item id
/// Message
/// Need for message address
/// Can hold any data
public static MobileNotificationMessage CreateMessage(string instituteCode, int instituteUserId, MobileNotificationMessageType notificationType, int itemId, string message, string title = "", string data = "")
{
return new MobileNotificationMessage(instituteCode, instituteUserId, MobileNotificationMessageRole.Student | MobileNotificationMessageRole.Tutelary, notificationType, MobileNotificationMessageSource.Kreta, MobileNotificationMessageDestination.RoleGroup, itemId, message, title, data);
}
///
/// Send message asynchronously
///
/// Institute code
/// Institute user id
/// Item id
/// Message
/// Notification type
public static async Task PostStudentNotificationAsync(string instituteCode, int instituteUserId, MobileNotificationMessageType notificationType, int itemId, string message)
{
await DependencyContainer.Instance.GetInstance().PostAsync(new MobileNotificationMessage(instituteCode, instituteUserId, MobileNotificationMessageRole.Student | MobileNotificationMessageRole.Tutelary, notificationType, MobileNotificationMessageSource.Kreta, MobileNotificationMessageDestination.RoleGroup, itemId, message));
}
///
/// Bulk send messages asynchronously
///
/// Üzenetek
public static async Task PostStudentNotificationAsync(MobileNotificationMessage[] messages)
{
await DependencyContainer.Instance.GetInstance().PostAsync(messages);
}
///
/// Send message
///
/// Institute code
/// Institute user id
/// Item id
/// Message
/// Notification type
/// We wrap calls into a task to avoid callbacks to current http syncronization context (because hosting thread may be destructed)
public static void PostStudentNotification(string instituteCode, int instituteUserId, MobileNotificationMessageType notificationType, int itemId, string message)
{
DependencyContainer.Instance.GetInstance().Post(new MobileNotificationMessage(instituteCode, instituteUserId, MobileNotificationMessageRole.Student | MobileNotificationMessageRole.Tutelary, notificationType, MobileNotificationMessageSource.Kreta, MobileNotificationMessageDestination.RoleGroup, itemId, message));
}
///
/// Send message
///
/// Institute code
/// Institute user id
/// Item id
/// Message
/// Notification type
///
/// -
/// 2
/// Evaluation
///
/// -
/// 4
/// Absence
///
/// -
/// 8
/// Note
///
/// -
/// 16
/// Message
///
/// -
/// 32
/// Homework
///
/// -
/// 64
/// Exam
///
///
///
/// We wrap calls into a task to avoid callbacks to current http syncronization context (because hosting thread may be destructed)
public static void PostStudentTestNotification(string instituteCode, int instituteUserId, int notificationType, int itemId, string message)
{
DependencyContainer.Instance.GetInstance().Post(new MobileNotificationMessage(instituteCode, instituteUserId, MobileNotificationMessageRole.Student | MobileNotificationMessageRole.Tutelary, (MobileNotificationMessageType)notificationType, MobileNotificationMessageSource.Kreta, MobileNotificationMessageDestination.RoleGroup, itemId, message));
}
///
/// Bulk send messages
///
/// Üzenetek
public static void PostStudentNotification(MobileNotificationMessage[] messages)
{
DependencyContainer.Instance.GetInstance().Post(messages);
}
#endregion
}
}