public static async Task <HttpResponseMessage> Push(NotifData notifData, string id, Subject subject, EventType eventType) { List <GridData> eventList = new List <GridData>(); var eventItem = new GridData { Subject = subject.ToString(), EventType = "durashop.notification." + eventType.ToString(), EventTime = DateTime.UtcNow, Id = id, Data = notifData }; eventList.Add(eventItem); return(await PostToEventGridAsync(eventList)); }
public static async Task PushNotification(NotifData notifData, string id, string subject, string eventType) { var credentials = new Microsoft.Azure.EventGrid.Models.TopicCredentials(sasKey); var client = new Microsoft.Azure.EventGrid.EventGridClient(credentials); var eventGridEvent = new Microsoft.Azure.EventGrid.Models.EventGridEvent { Subject = subject, EventType = eventType, EventTime = DateTime.UtcNow, Id = id, Data = notifData, DataVersion = "1.0.0", }; var events = new List <Microsoft.Azure.EventGrid.Models.EventGridEvent>(); events.Add(eventGridEvent); await client.PublishEventsWithHttpMessagesAsync(topicHostName, events); }