/// <summary> /// Parses the message. /// </summary> /// <param name="notification">The notification.</param> /// <param name="c">The c.</param> /// <returns></returns> public NotificationMessageContent ParseMessage(NotificationTemplates notification, NotificationMessageCurlys c) { var content = Resolve(notification.Message, notification.Subject, c.Curlys); content.Image = c.PosterImage; return(content); }
public static Notifications GetEmail(NotificationTemplates template, UserInfo user, Dictionary <string, string> dictionary, string body) { var notification = new Notifications(); notification.Status = "Pending"; notification.Title = template.Title; notification.Subject = Replace(template.Subject, dictionary); notification.Body = body; notification.Application = template.Application; notification.IsAnnouncment = template.Frequency != "Real Time"; if (template.RecipientType == "User") { notification.Recipient = user.Email; } else if (template.RecipientType == "Group") { // If the group is email enabled, go ahead and just email the DL, otherwise, get each user in the groups email. if (SharePointHelper.EmailSharePointGroup) { notification.Recipient = template.RecipientColumn + "@omb.gov"; } else { notification.Recipient = GetGroupEmails(template.RecipientColumn); } } if (template.IncludeCc) { notification.Cc = dictionary["Cc"]; } return(notification); }
private NotificationMessageContent Parse(NotificationOptions model, NotificationTemplates template, NotificationAgent agent) { var resolver = new NotificationMessageResolver(); var curlys = new NotificationMessageCurlys(); var preference = GetUserPreference(model.UserId, agent); if (model.RequestType == RequestType.Movie) { _log.LogDebug("Notification options: {@model}, Req: {@MovieRequest}, Settings: {@Customization}", model, MovieRequest, Customization); curlys.Setup(model, MovieRequest, Customization, preference); } else if (model.RequestType == RequestType.TvShow) { _log.LogDebug("Notification options: {@model}, Req: {@TvRequest}, Settings: {@Customization}", model, TvRequest, Customization); curlys.Setup(model, TvRequest, Customization, preference); } else if (model.RequestType == RequestType.Album) { _log.LogDebug("Notification options: {@model}, Req: {@AlbumRequest}, Settings: {@Customization}", model, AlbumRequest, Customization); curlys.Setup(model, AlbumRequest, Customization, preference); } var parsed = resolver.ParseMessage(template, curlys); return(parsed); }
private async Task SendIndividualEmails(MassEmailModel model, CustomizationSettings customization, EmailNotificationSettings email, List <Task> messagesSent) { var resolver = new NotificationMessageResolver(); var curlys = new NotificationMessageCurlys(); foreach (var user in model.Users) { var fullUser = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == user.Id); if (!fullUser.Email.HasValue()) { _log.LogInformation("User {0} has no email, cannot send mass email to this user", fullUser.UserName); continue; } curlys.Setup(fullUser, customization); var template = new NotificationTemplates() { Message = model.Body, Subject = model.Subject }; var content = resolver.ParseMessage(template, curlys); var msg = new NotificationMessage { Message = content.Message, To = fullUser.Email, Subject = content.Subject }; messagesSent.Add(DelayEmail(msg, email)); _log.LogInformation("Sent mass email to user {0} @ {1}", fullUser.UserName, fullUser.Email); } }
public async Task <NotificationTemplates> Insert(NotificationTemplates entity) { var settings = await Db.NotificationTemplates.AddAsync(entity).ConfigureAwait(false); await InternalSaveChanges().ConfigureAwait(false); return(settings.Entity); }
public async Task Update(NotificationTemplates template) { if (Db.Entry(template).State == EntityState.Detached) { Db.Attach(template); Db.Entry(template).State = EntityState.Modified; } await InternalSaveChanges(); }
private NotificationMessageContent ParseTemplate(NotificationTemplates template, CustomizationSettings settings, OmbiUser username) { var resolver = new NotificationMessageResolver(); var curlys = new NotificationMessageCurlys(); curlys.SetupNewsletter(settings, username); return(resolver.ParseMessage(template, curlys)); }
private NotificationMessageContent Parse(OmbiUser u, NotificationTemplates template, CustomizationSettings cs) { var resolver = new NotificationMessageResolver(); var curlys = new NotificationMessageCurlys(); curlys.Setup(u, cs); var parsed = resolver.ParseMessage(template, curlys); return(parsed); }
public static Notifications GetEmail(string notificationType, UserInfo user, Dictionary <string, string> dictionary, string body) { var template = NotificationTemplates.GetBy("Title", notificationType); if (string.IsNullOrEmpty(body)) { body = Replace(template.Body, dictionary); } return(GetEmail(template, user, dictionary, body)); }
private static void GenerateEmailsForOGEForm450(NotificationTemplates template) { var items = OGEForm450.GetAllByView(template.ViewName); foreach (OGEForm450 item in items) { var user = UserInfo.GetUser(item.Filer); var email = GetEmail(template, user, item.GetEmailData(user)); EmailHelper.AddEmail(email); } }
public NotificationTemplateEntity GetNotificationTemplateByNotification(string notificationTypeId, string objectId, string objectTypeId, string language) { var query = NotificationTemplates.Where(x => x.NotificationTypeId == notificationTypeId && x.ObjectId == objectId && x.ObjectTypeId == objectTypeId); var retVal = query.Where(x => x.Language == null || x.Language == language).OrderByDescending(x => x.Language).FirstOrDefault(); if (retVal == null) { retVal = query.FirstOrDefault(x => x.IsDefault); } return(retVal); }
public NotificationTemplateEntity GetNotificationTemplateByNotification(string notificationTypeId, string objectId, string objectTypeId, string language) { var query = NotificationTemplates.Where(nt => nt.NotificationTypeId.Equals(notificationTypeId) && nt.ObjectId.Equals(objectId) && nt.ObjectTypeId.Equals(objectTypeId)); var retVal = query.FirstOrDefault(nt => nt.Language.Equals(language)); if (retVal == null) { retVal = query.FirstOrDefault(nt => nt.IsDefault); } return(retVal); }
private static void GenerateNewEmails() { // get all templates that are enabled and not real time var templates = NotificationTemplates.GetAll().Where(x => x.Enabled == true && x.Frequency != "Real Time").ToList(); foreach (NotificationTemplates template in templates) { // Check for next run date if ((template.NextRunDate ?? DateTime.MaxValue) <= DateTime.UtcNow) { GenerateEmailsFromTemplate(template); } } }
public void ShouldConstructCorrectly() { var nt = new NotificationTemplates("abc", "def", "ghi", "jkl", "mno", "pqr", "stu", "bcd", "efg", "hij", "klm", "vwx", "yza"); // assert Assert.AreEqual("abc", nt.EmailRcSubject); Assert.AreEqual("def", nt.EmailRcTemplate); Assert.AreEqual("ghi", nt.EmailStalkTemplate); Assert.AreEqual("jkl", nt.EmailGreeting); Assert.AreEqual("mno", nt.EmailSignature); Assert.AreEqual("pqr", nt.EmailStalkReport); Assert.AreEqual("stu", nt.EmailStalkReportSubject); Assert.AreEqual("vwx", nt.IrcAlertFormat); Assert.AreEqual("yza", nt.IrcStalkTagSeparator); }
private async Task SendBccMails(MassEmailModel model, CustomizationSettings customization, EmailNotificationSettings email, List <Task> messagesSent) { var resolver = new NotificationMessageResolver(); var curlys = new NotificationMessageCurlys(); var validUsers = new List <OmbiUser>(); foreach (var user in model.Users) { var fullUser = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == user.Id); if (!fullUser.Email.HasValue()) { _log.LogInformation("User {0} has no email, cannot send mass email to this user", fullUser.UserName); continue; } validUsers.Add(fullUser); } if (!validUsers.Any()) { return; } var firstUser = validUsers.FirstOrDefault(); var bccAddress = string.Join(',', validUsers.Select(x => x.Email)); curlys.Setup(firstUser, customization); var template = new NotificationTemplates() { Message = model.Body, Subject = model.Subject }; var content = resolver.ParseMessage(template, curlys); var msg = new NotificationMessage { Message = content.Message, Subject = content.Subject, Other = new Dictionary <string, string> { { "bcc", bccAddress } } }; messagesSent.Add(_email.SendAdHoc(msg, email)); }
private NotificationMessageContent Parse(NotificationOptions model, NotificationTemplates template) { var resolver = new NotificationMessageResolver(); var curlys = new NotificationMessageCurlys(); if (model.RequestType == RequestType.Movie) { _log.LogDebug("Notification options: {@model}, Req: {@MovieRequest}, Settings: {@Customization}", model, MovieRequest, Customization); curlys.Setup(model, MovieRequest, Customization); } else { _log.LogDebug("Notification options: {@model}, Req: {@TvRequest}, Settings: {@Customization}", model, TvRequest, Customization); curlys.Setup(model, TvRequest, Customization); } var parsed = resolver.ParseMessage(template, curlys); return(parsed); }
public IHttpActionResult Update(NotificationTemplates item) { try { var identity = HttpContext.Current.User.Identity as ClaimsIdentity; AppUser = UserInfo.GetUser(identity); if (AppUser.IsAdmin) { return(Json(item.Save(), CamelCase)); } else { return(Unauthorized()); } } catch (Exception ex) { return(HandleException(ex)); } }
public async Task <bool> SendMassEmail(MassEmailModel model) { var customization = await _customizationService.GetSettingsAsync(); var email = await _emailService.GetSettingsAsync(); var messagesSent = new List <Task>(); foreach (var user in model.Users) { var fullUser = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == user.Id); if (!fullUser.Email.HasValue()) { _log.LogInformation("User {0} has no email, cannot send mass email to this user", fullUser.UserName); continue; } var resolver = new NotificationMessageResolver(); var curlys = new NotificationMessageCurlys(); curlys.Setup(fullUser, customization); var template = new NotificationTemplates() { Message = model.Body, Subject = model.Subject }; var content = resolver.ParseMessage(template, curlys); var msg = new NotificationMessage { Message = content.Message, To = fullUser.Email, Subject = content.Subject }; messagesSent.Add(_email.SendAdHoc(msg, email)); _log.LogInformation("Sent mass email to user {0} @ {1}", fullUser.UserName, fullUser.Email); } await Task.WhenAll(messagesSent); return(true); }
public IHttpActionResult Get(int id) { try { var identity = HttpContext.Current.User.Identity as ClaimsIdentity; OGE450User = UserInfo.GetUser(identity); if (OGE450User.IsAdmin) { var template = NotificationTemplates.Get(id); return(Json(template, CamelCase)); } else { return(Unauthorized()); } } catch (Exception ex) { return(HandleException(ex)); } }
public IHttpActionResult Get() { try { var identity = HttpContext.Current.User.Identity as ClaimsIdentity; AppUser = UserInfo.GetUser(identity); if (AppUser.IsAdmin) { var templates = NotificationTemplates.GetAllBy("Application", Constants.ApplicationName.EVENT_CLEARANCE); return(Json(templates.OrderBy(x => x.Title), CamelCase)); } else { return(Unauthorized()); } } catch (Exception ex) { return(HandleException(ex)); } }
private static void GenerateEmailsFromTemplate(NotificationTemplates template) { var status = "Success"; try { // Based on List, generate emails, currently only OGEForm450 templates are available if (template.SharePointList == "OGEForm450") { GenerateEmailsForOGEForm450(template); } } catch (Exception ex) { status = "Error: " + ex.Message; } finally { // This may seem a little weird, why not just add frequency to DateTime.Now? // Well, eventually that would get skewed if this process takes any time to run. We want the time of day to be consistent. // So if Next Run Date is set to Midnight, it will always be at midnight. // The loop is basically just here in case it gets stuck or set back way in the past. // The loop ensures that the next run date that is set will be in the future. // Update Next Run Date while (template.NextRunDate < DateTime.UtcNow) { template.NextRunDate = GetNextRunDate((DateTime)template.NextRunDate, template.Frequency); } template.LastRunDate = DateTime.UtcNow; template.LastRunStatus = status; template.Save(); } }
public async Task AddQueueNotification(NotificationTemplates template, int id, Guid userGuid, string queueName = null) { try { // Create Message. var message = new QueueNotification { TemplateName = template, Identifier = id, UserGuid = userGuid, TimestampOffset = DateTimeOffset.UtcNow }; var cloudQueueMessage = new CloudQueueMessage(JsonConvert.SerializeObject(message)); // Add to Queue. var queue = await GetQueue(queueName ?? ConfigurationManager.AppSettings["NotificationQueue"]); await queue.AddMessageAsync(cloudQueueMessage).ConfigureAwait(false); } catch (Exception ex) { Logger.LogException(ex); } }
public static string GetEmailText(string notificationType, Dictionary <string, string> dictionary) { var template = NotificationTemplates.GetBy("Title", notificationType); return(Replace(template.Body, dictionary)); }
public static Notifications GetEmail(string notificationType, UserInfo user, Dictionary <string, string> dictionary) { var template = NotificationTemplates.GetBy("Title", notificationType); return(GetEmail(template, user, dictionary)); }
public void Seed() { // Make sure we have the API User var apiUserExists = Users.Any(x => x.UserName.Equals("Api", StringComparison.CurrentCultureIgnoreCase)); if (!apiUserExists) { Users.Add(new OmbiUser { UserName = "******", UserType = UserType.SystemUser, NormalizedUserName = "******", }); SaveChanges(); } //Check if templates exist var templates = NotificationTemplates.ToList(); var allAgents = Enum.GetValues(typeof(NotificationAgent)).Cast <NotificationAgent>().ToList(); var allTypes = Enum.GetValues(typeof(NotificationType)).Cast <NotificationType>().ToList(); foreach (var agent in allAgents) { foreach (var notificationType in allTypes) { if (templates.Any(x => x.Agent == agent && x.NotificationType == notificationType)) { // We already have this continue; } NotificationTemplates notificationToAdd; switch (notificationType) { case NotificationType.NewRequest: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! The user '{UserName}' has requested the {Type} '{Title}'! Please log in to approve this request. Request Date: {RequestedDate}", Subject = "{ApplicationName}: New {Type} request for {Title}!", Agent = agent, Enabled = true, }; break; case NotificationType.Issue: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! The user '{UserName}' has reported a new issue for the title {Title}! </br> {IssueCategory} - {IssueSubject} : {IssueDescription}", Subject = "{ApplicationName}: New issue for {Title}!", Agent = agent, Enabled = true, }; break; case NotificationType.RequestAvailable: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! Your request for {Title} on {ApplicationName}! This is now available! :)", Subject = "{ApplicationName}: {Title} is now available!", Agent = agent, Enabled = true, }; break; case NotificationType.RequestApproved: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! Your request for {Title} has been approved!", Subject = "{ApplicationName}: your request has been approved", Agent = agent, Enabled = true, }; break; case NotificationType.Test: continue; case NotificationType.RequestDeclined: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! Your request for {Title} has been declined, Sorry!", Subject = "{ApplicationName}: your request has been declined", Agent = agent, Enabled = true, }; break; case NotificationType.ItemAddedToFaultQueue: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! The user '{UserName}' has requested {Title} but it could not be added. This has been added into the requests queue and will keep retrying", Subject = "Item Added To Retry Queue", Agent = agent, Enabled = true, }; break; case NotificationType.WelcomeEmail: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! You have been invited to use {ApplicationName}! You can login here: {ApplicationUrl}", Subject = "Invite to {ApplicationName}", Agent = agent, Enabled = true, }; break; case NotificationType.IssueResolved: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello {UserName} Your issue for {Title} has now been resolved.", Subject = "{ApplicationName}: Issue has been resolved for {Title}!", Agent = agent, Enabled = true, }; break; case NotificationType.IssueComment: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello, There is a new comment on your issue {IssueSubject}, The comment is: {NewIssueComment}", Subject = "{ApplicationName}: New comment on issue {IssueSubject}!", Agent = agent, Enabled = true, }; break; case NotificationType.AdminNote: continue; case NotificationType.Newsletter: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Here is a list of Movies and TV Shows that have recently been added!", Subject = "{ApplicationName}: Recently Added Content!", Agent = agent, Enabled = true, }; break; default: throw new ArgumentOutOfRangeException(); } NotificationTemplates.Add(notificationToAdd); } } SaveChanges(); }
public void Seed() { // Add the tokens var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv); if (fanArt == null) { ApplicationConfigurations.Add(new ApplicationConfiguration { Type = ConfigurationTypes.FanartTv, Value = "4b6d983efa54d8f45c68432521335f15" }); SaveChanges(); } var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv); if (movieDb == null) { ApplicationConfigurations.Add(new ApplicationConfiguration { Type = ConfigurationTypes.TheMovieDb, Value = "b8eabaf5608b88d0298aa189dd90bf00" }); SaveChanges(); } var notification = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Notification); if (notification == null) { ApplicationConfigurations.Add(new ApplicationConfiguration { Type = ConfigurationTypes.Notification, Value = "4f0260c4-9c3d-41ab-8d68-27cb5a593f0e" }); SaveChanges(); } // VACUUM; Database.ExecuteSqlCommand("VACUUM;"); // Make sure we have the roles var roles = Roles.Where(x => x.Name == OmbiRoles.RecievesNewsletter); if (!roles.Any()) { Roles.Add(new IdentityRole(OmbiRoles.RecievesNewsletter) { NormalizedName = OmbiRoles.RecievesNewsletter.ToUpper() }); SaveChanges(); } // Make sure we have the API User var apiUserExists = Users.Any(x => x.UserName.Equals("Api", StringComparison.CurrentCultureIgnoreCase)); if (!apiUserExists) { Users.Add(new OmbiUser { UserName = "******", UserType = UserType.SystemUser, NormalizedUserName = "******", }); SaveChanges(); } //Check if templates exist var templates = NotificationTemplates.ToList(); var allAgents = Enum.GetValues(typeof(NotificationAgent)).Cast <NotificationAgent>().ToList(); var allTypes = Enum.GetValues(typeof(NotificationType)).Cast <NotificationType>().ToList(); foreach (var agent in allAgents) { foreach (var notificationType in allTypes) { if (templates.Any(x => x.Agent == agent && x.NotificationType == notificationType)) { // We already have this continue; } NotificationTemplates notificationToAdd; switch (notificationType) { case NotificationType.NewRequest: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! The user '{UserName}' has requested the {Type} '{Title}'! Please log in to approve this request. Request Date: {RequestedDate}", Subject = "{ApplicationName}: New {Type} request for {Title}!", Agent = agent, Enabled = true, }; break; case NotificationType.Issue: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! The user '{UserName}' has reported a new issue for the title {Title}! </br> {IssueCategory} - {IssueSubject} : {IssueDescription}", Subject = "{ApplicationName}: New issue for {Title}!", Agent = agent, Enabled = true, }; break; case NotificationType.RequestAvailable: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! You {Title} on {ApplicationName}! This is now available! :)", Subject = "{ApplicationName}: {Title} is now available!", Agent = agent, Enabled = true, }; break; case NotificationType.RequestApproved: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! Your request for {Title} has been approved!", Subject = "{ApplicationName}: your request has been approved", Agent = agent, Enabled = true, }; break; case NotificationType.Test: continue; case NotificationType.RequestDeclined: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! Your request for {Title} has been declined, Sorry!", Subject = "{ApplicationName}: your request has been declined", Agent = agent, Enabled = true, }; break; case NotificationType.ItemAddedToFaultQueue: continue; case NotificationType.WelcomeEmail: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! You have been invited to use {ApplicationName}! You can login here: {ApplicationUrl}", Subject = "Invite to {ApplicationName}", Agent = agent, Enabled = true, }; break; case NotificationType.IssueResolved: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello {UserName} Your issue for {Title} has now been resolved.", Subject = "{ApplicationName}: Issue has been resolved for {Title}!", Agent = agent, Enabled = true, }; break; case NotificationType.IssueComment: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello, There is a new comment on your issue {IssueSubject}, The comment is: {NewIssueComment}", Subject = "{ApplicationName}: New comment on issue {IssueSubject}!", Agent = agent, Enabled = true, }; break; case NotificationType.AdminNote: continue; case NotificationType.Newsletter: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Here is a list of Movies and TV Shows that have recently been added!", Subject = "{ApplicationName}: Recently Added Content!", Agent = agent, Enabled = true, }; break; default: throw new ArgumentOutOfRangeException(); } NotificationTemplates.Add(notificationToAdd); } } SaveChanges(); }
public static Notifications GetEmail(NotificationTemplates template, UserInfo user, Dictionary <string, string> dictionary) { var body = Replace(template.Body, dictionary); return(GetEmail(template, user, dictionary, body)); }
public async Task Update(NotificationTemplates template) { await Db.SaveChangesAsync(); }
public void Seed() { var strat = Database.CreateExecutionStrategy(); strat.Execute(() => { using (var tran = Database.BeginTransaction()) { // Make sure we have the API User var apiUserExists = Users.ToList().Any(x => x.NormalizedUserName == "API"); if (!apiUserExists) { Users.Add(new OmbiUser { UserName = "******", UserType = UserType.SystemUser, NormalizedUserName = "******", StreamingCountry = "US" }); SaveChanges(); tran.Commit(); } } }); //Check if templates exist var templates = NotificationTemplates.ToList(); var allAgents = Enum.GetValues(typeof(NotificationAgent)).Cast <NotificationAgent>().ToList(); var allTypes = Enum.GetValues(typeof(NotificationType)).Cast <NotificationType>().ToList(); var needToSave = false; foreach (var agent in allAgents) { foreach (var notificationType in allTypes) { if (templates.Any(x => x.Agent == agent && x.NotificationType == notificationType)) { // We already have this continue; } needToSave = true; NotificationTemplates notificationToAdd = null; switch (notificationType) { case NotificationType.NewRequest: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! The user '{UserName}' has requested the {Type} '{Title}'! Please log in to approve this request. Request Date: {RequestedDate}", Subject = "{ApplicationName}: New {Type} request for {Title}!", Agent = agent, Enabled = true, }; break; case NotificationType.Issue: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! The user '{UserName}' has reported a new issue for the title {Title}! </br> {IssueCategory} - {IssueSubject} : {IssueDescription}", Subject = "{ApplicationName}: New issue for {Title}!", Agent = agent, Enabled = true, }; break; case NotificationType.RequestAvailable: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! Your request for {Title} on {ApplicationName} is now available! :)", Subject = "{ApplicationName}: {Title} is now available!", Agent = agent, Enabled = true, }; break; case NotificationType.RequestApproved: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! Your request for {Title} has been approved!", Subject = "{ApplicationName}: your request has been approved", Agent = agent, Enabled = true, }; break; case NotificationType.Test: continue; case NotificationType.RequestDeclined: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! Your request for {Title} has been declined, Sorry!", Subject = "{ApplicationName}: your request has been declined", Agent = agent, Enabled = true, }; break; case NotificationType.ItemAddedToFaultQueue: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! The user '{UserName}' has requested {Title} but it could not be added. This has been added into the requests queue and will keep retrying", Subject = "Item Added To Retry Queue", Agent = agent, Enabled = true, }; break; case NotificationType.WelcomeEmail: if (agent == NotificationAgent.Email) { notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello! You have been invited to use {ApplicationName}! You can login here: {ApplicationUrl}", Subject = "Invite to {ApplicationName}", Agent = agent, Enabled = true, }; } break; case NotificationType.IssueResolved: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello {UserName} Your issue for {Title} has now been resolved.", Subject = "{ApplicationName}: Issue has been resolved for {Title}!", Agent = agent, Enabled = true, }; break; case NotificationType.IssueComment: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Hello, There is a new comment on your issue {IssueSubject}, The comment is: {NewIssueComment}", Subject = "{ApplicationName}: New comment on issue {IssueSubject}!", Agent = agent, Enabled = true, }; break; case NotificationType.AdminNote: continue; case NotificationType.Newsletter: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Here is a list of Movies and TV Shows that have recently been added!", Subject = "{ApplicationName}: Recently Added Content!", Agent = agent, Enabled = true, }; break; case NotificationType.PartiallyAvailable: notificationToAdd = new NotificationTemplates { NotificationType = notificationType, Message = "Your TV request is now partially available! Season {PartiallyAvailableSeasonNumber} Episodes {PartiallyAvailableEpisodeNumbers}!", Subject = "{ApplicationName}: Partially Available Request!", Agent = agent, Enabled = true, }; break; default: throw new ArgumentOutOfRangeException(); } if (notificationToAdd != null) { NotificationTemplates.Add(notificationToAdd); } } } if (needToSave) { strat.Execute(() => { using (var tran = Database.BeginTransaction()) { SaveChanges(); tran.Commit(); } }); } }