public async Task<ActionResult> LogEventSubscriptions() { var dbContext = new NotificationDb(); var logEventSub = new LogEventSubscriptions { Id = Guid.NewGuid(), ObjectTypeOfEvent = Enum.ObjectTypeOfEvent.MonthlyMeeting, EventType = Enum.EventType.Delete, UserWhoSubscribed = "*****@*****.**" }; dbContext.LogEventSubscriptionses.Add(logEventSub); await dbContext.SaveChangesAsync(); return Content("Created new row"); }
public async Task<ActionResult> LogEvents() { var dbContext = new NotificationDb(); var logEvent = new LogEvents() { EventType = Enum.EventType.Delete, Id = Guid.NewGuid(), UserWhoCreatesEvent = "*****@*****.**", ObjectTypeOfEvent = Enum.ObjectTypeOfEvent.MonthlyMeeting }; dbContext.LogEventses.Add(logEvent); await dbContext.SaveChangesAsync(); var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ToString()); CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); CloudQueue queue = queueClient.GetQueueReference("logeventslog"); queue.CreateIfNotExists(); var queueMessage = new CloudQueueMessage(JsonConvert.SerializeObject(logEvent)); queue.AddMessage(queueMessage); //List<string> c = dbContext.LogEventSubscriptionses.Where(r => r.EventType == logEvent.EventType // && r.ObjectTypeOfEvent == logEvent.ObjectTypeOfEvent).Select(r => r.UserWhoSubscribed).ToList(); //var mandrill = new MandrillApi(ConfigurationManager.AppSettings["MandrillApiKey"]); //foreach (var row in c) //{ // var email = new EmailMessage // { // Text = "body", // FromEmail = "*****@*****.**", // To = new List<EmailAddress> {new EmailAddress {Email = row}}, // Subject = "Sub" // }; // await mandrill.SendMessage(new SendMessageRequest(email)); //} return Content("new row created"); }
public static void ProcessQueueMessage([QueueTrigger("logeventslog")] LogEvents logEvent, TextWriter log) { var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ToString()); var blobClient = storageAccount.CreateCloudBlobClient(); var dbContext = new NotificationDb(); List<string> c = dbContext.LogEventSubscriptionses.Where(r => r.EventType == logEvent.EventType && r.ObjectTypeOfEvent == logEvent.ObjectTypeOfEvent) .Select(r => r.UserWhoSubscribed).ToList(); var y = new LogEventSubscriptions() { UserWhoSubscribed = "*****@*****.**", Id = Guid.NewGuid() }; dbContext.LogEventSubscriptionses.Add(y); dbContext.SaveChanges(); //var mandrill = new MandrillApi(ConfigurationManager.AppSettings["MandrillApiKey"]); //foreach (var row in c) //{ // var email = new EmailMessage // { // Text = "body", // FromEmail = "*****@*****.**", // To = new List<EmailAddress> { new EmailAddress { Email = row } }, // Subject = "Sub" // }; // mandrill.SendMessage(new SendMessageRequest(email)); //} }
public async Task<ActionResult> NotificationUserID() { var notificationContext = new NotificationDb(); var notificationSignaldbSet = new NotificationSignalR() { Id = 1, RecipientOrganizationId = 4536, RecipientUserId = 2, Seen = false }; notificationContext.NotificationSignalRs.Add(notificationSignaldbSet); await notificationContext.SaveChangesAsync(); return Content("new row has been created in notificationDBSET"); }