public void ReadEmailGroupFromXmlUsingAlwaysNotificationType() { EmailGroup group = (EmailGroup)NetReflector.Read(@"<group name=""foo""> <notifications><NotificationType>Always</NotificationType></notifications> </group>"); Assert.AreEqual("foo", group.Name); Assert.IsTrue(group.HasNotification(EmailGroup.NotificationType.Always)); }
public void ReadEmailGroupFromXmlUsingMulipleNotificationTypes() { EmailGroup group = (EmailGroup)NetReflector.Read(@"<group name=""foo""> <notifications><NotificationType>Failed</NotificationType><NotificationType>Fixed</NotificationType><NotificationType>Exception</NotificationType></notifications> </group> "); Assert.IsTrue(group.HasNotification(EmailGroup.NotificationType.Exception)); Assert.IsTrue(group.HasNotification(EmailGroup.NotificationType.Fixed)); Assert.IsTrue(group.HasNotification(EmailGroup.NotificationType.Failed)); Assert.IsFalse(group.HasNotification(EmailGroup.NotificationType.Change)); }
protected override void InitializeTest() { this.group1 = new EmailGroup() { Id = 1, Name = "SomeGroupName" }; this.DbContext.EmailGroups.Add(this.group1); this.DbContext.SaveChanges(); this.service = new EmailGroupsDbValidatorService(this.DbContext); }
protected override void InitializeTest() { this.group1 = new EmailGroup() { Id = 1, Name = "Group1", Emails = new List <Email>() { new Email() { Id = 1, Address = "*****@*****.**" }, new Email() { Id = 2, Address = "*****@*****.**" }, } }; this.group2 = new EmailGroup() { Id = 2, Name = "Group2", Emails = new List <Email>() { new Email() { Id = 3, Address = "*****@*****.**" }, new Email() { Id = 4, Address = "*****@*****.**" }, } }; this.DbContext.EmailGroups.AddRange(this.group1, this.group2); this.DbContext.SaveChanges(); var validatorServiceMock = new Mock <IEmailGroupsDbValidatorService>(); validatorServiceMock .Setup(m => m.ThrowIfGroupNameAlreadyExist(It.IsAny <string>())) .Returns(Task.CompletedTask); this.service = new EmailGroupService(this.DbContext, validatorServiceMock.Object); }
protected void btnSaveGroup_Click(object sender, EventArgs e) { string groupName = this.txtGroupName.Text.Trim(); string parentId = this.ddlParentGroupID.SelectedValue; string groupDescription = this.txtGroupDescription.Text.Trim(); using (var context = new EmailContext()) { if (this.hideGroupAction.Value == "add") { var entity = context.EmailGroups.FirstOrDefault(g => g.GroupName == groupName); if (entity == null) { entity = new EmailGroup { GroupName = groupName, ParentID = int.Parse(parentId), GroupDescription = groupDescription }; context.EmailGroups.Add(entity); context.SaveChanges(); this.txtGroupName.Text = string.Empty; this.txtGroupDescription.Text = string.Empty; } else { ScriptManager.RegisterStartupScript(this.GroupUpdatePanel, GetType(), "a", "alert('此分组名称已经存在')", true); return; } } if (this.hideGroupAction.Value == "edit") { var id = this.hideGroupID.Value; var entity = context.EmailGroups.Find(int.Parse(id)); if (entity != null) { entity.GroupName = groupName; entity.ParentID = int.Parse(parentId); entity.GroupDescription = groupDescription; } context.SaveChanges(); this.txtGroupName.Text = string.Empty; this.ddlParentGroupID.SelectedIndex = -1; this.txtGroupDescription.Text = string.Empty; this.hideGroupID.Value = "0"; this.hideGroupAction.Value = "add"; } } InitRepeater4(this.AspNetPager4.CurrentPageIndex); ddlParentGroupID_GetData(); }
public bool Delete(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { EmailGroup group = context.EmailGroups.FirstOrDefault(c => c.ID == id); if (group != null) { context.EmailGroups.DeleteObject(group); context.SaveChanges(); return(true); } else { return(false); } } }
public List <EmailAddress> GetEmailsByGroup(EmailGroup emailGroupName) { List <EmailAddress> emailAddresses = null; List <KeyValuePair <string, object> > param = new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("@groupname", emailGroupName.ToString()) }; var dtTemplate = DataExecutor.ExecuteDataTable(UtilityConstant.Procedures.Mst_GetEmailGroup, param); if (dtTemplate != null && dtTemplate.Rows.Count > 0 && dtTemplate.Columns.Contains("Emails")) { emailAddresses = dtTemplate.Rows[0]["Emails"].ToString().Split(",").Select(x => new EmailAddress() { Address = x.Trim(), Name = string.Empty }).ToList(); } return(emailAddresses); }
public EmailGroup Save(EmailGroup model) { using (LoanPriceEntities context = new LoanPriceEntities()) { if (model.ID <= 0) { context.EmailGroups.AddObject(model); } else { context.EmailGroups.Attach(model); context.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified); } context.SaveChanges(); return(model); } }
public void PopulateFromConfiguration() { publisher = EmailPublisherMother.Create(); Assert.AreEqual("smtp.telus.net", publisher.MailHost); Assert.AreEqual(26, publisher.MailPort); Assert.AreEqual("mailuser", publisher.MailhostUsername); Assert.IsNotNull(publisher.MailhostPassword); Assert.AreEqual("mailpassword", publisher.MailhostPassword.PrivateValue); Assert.AreEqual("*****@*****.**", publisher.FromAddress); Assert.AreEqual(2, publisher.ModifierNotificationTypes.Length); Assert.AreEqual(EmailGroup.NotificationType.Failed, publisher.ModifierNotificationTypes[0]); Assert.AreEqual(EmailGroup.NotificationType.Fixed, publisher.ModifierNotificationTypes[1]); Assert.AreEqual(1, publisher.Converters.Length); Assert.AreEqual("$", ((EmailRegexConverter)publisher.Converters[0]).Find); Assert.AreEqual("@TheCompany.com", ((EmailRegexConverter)publisher.Converters[0]).Replace); Assert.AreEqual(6, publisher.IndexedEmailUsers.Count); var expected = new List <EmailUser>(); expected.Add(new EmailUser("buildmaster", "buildmaster", "*****@*****.**")); expected.Add(new EmailUser("orogers", "developers", "*****@*****.**")); expected.Add(new EmailUser("manders", "developers", "*****@*****.**")); expected.Add(new EmailUser("dmercier", "developers", "*****@*****.**")); expected.Add(new EmailUser("rwan", "developers", "*****@*****.**")); expected.Add(new EmailUser("owjones", "successdudes", "*****@*****.**")); for (int i = 0; i < expected.Count; i++) { Assert.IsTrue(publisher.IndexedEmailUsers.ContainsValue(expected[i])); } Assert.AreEqual(3, publisher.IndexedEmailGroups.Count); EmailGroup developers = new EmailGroup("developers", new EmailGroup.NotificationType[] { EmailGroup.NotificationType.Change }); EmailGroup buildmaster = new EmailGroup("buildmaster", new EmailGroup.NotificationType[] { EmailGroup.NotificationType.Always }); EmailGroup successdudes = new EmailGroup("successdudes", new EmailGroup.NotificationType[] { EmailGroup.NotificationType.Success }); Assert.AreEqual(developers, publisher.IndexedEmailGroups["developers"]); Assert.AreEqual(buildmaster, publisher.IndexedEmailGroups["buildmaster"]); Assert.AreEqual(successdudes, publisher.IndexedEmailGroups["successdudes"]); }
public bool SendEmail(Entities.MailjetEmail email) { try { //Convert this into the group the API can understand. EmailGroup group = new EmailGroup(); group.Messages = new Entities.MailjetEmail[] { email }; //Serialize this to JSON and send it to the API. EmailGroup reply = ToolsPrivate.SendPost <EmailGroup>(group, apiKey); //We can tell if it completed if all emails have good status. foreach (MailjetEmail e in reply.Messages) { if (e.Status != "success") { return(false); } } return(true); } catch (WebException wex) { Console.WriteLine(wex.Message); return(false); } }
public async Task <EmailGroupDto> Create(NewEmailGroupDto dto) { await this.validatorService.ThrowIfGroupNameAlreadyExist(dto.Name); var newGroup = new EmailGroup() { Name = dto.Name, Emails = dto.Emails.Select(item => new Email() { Address = item }).ToList() }; this.dbContext.EmailGroups.Add(newGroup); await this.dbContext.SaveChangesAsync(); return(new EmailGroupDto() { Id = newGroup.Id, Name = newGroup.Name, Emails = newGroup.Emails.Select(item => item.Address) }); }
public static void EmailSetting(int appId, int appTypeid, string emailType, out SmtpEmail smtpEmailObj, out EmailGroup objEmailGroup, out string mailTo) { EmailGroupDal objEmailGroupDal = new EmailGroupDal(); EmailConfigDetailDal objEmailConfigDetailDal = new EmailConfigDetailDal(); #region smtp Setting SmtpDetailsDal objSmtpDetailsDal = new SmtpDetailsDal(); try { SmtpDetail objSmtpDetail = objSmtpDetailsDal.GetAtiveSmtpDetails(); SmtpEmail.SmtpHost = objSmtpDetail.SmtpHost; SmtpEmail.SmtpUser = objSmtpDetail.SmtpUser; SmtpEmail.SmtpPwd = objSmtpDetail.Password; smtpEmailObj = SmtpEmail.GetSmtpEmailInstance(); #endregion //"Validation" to appconfig objEmailGroup = objEmailGroupDal.GetEmailGroupByApptypeIdAndEmailType(appTypeid, emailType); #region Emailto Setting var toemailList = objEmailConfigDetailDal.GetEmailListByGroupIdAndAppId(objEmailGroup.Id, appId); mailTo = ""; for (int index = 0; index < toemailList.Count; index++) { if (index == toemailList.Count - 1) { mailTo += toemailList[index]; } else { mailTo += toemailList[index] + ","; } } } catch (Exception ex) { throw; } #endregion }
/// <summary> /// /// </summary> /// <param name="category"></param> /// <param name="group"></param> /// <param name="???"></param> /// <returns></returns> public List <Message> Search(Category category, EmailGroup group, string pattern) { }
/// <summary> /// "View {group} grouped by {category} sorted {sortType} {order} /// </summary> /// <param name="group"></param> /// <param name="category"></param> /// <param name="sortType"></param> /// <param name="order"></param> /// <returns></returns> public List <Message> Get(EmailGroup group, Category category, SortingType sortType, Order order) { }
public void ReadEmailGroupFromXmlUsingExceptionNotificationType() { EmailGroup group = (EmailGroup)NetReflector.Read(@"<group name=""foo""> <notifications><NotificationType>Exception</NotificationType></notifications> </group>"); Assert.IsTrue(group.HasNotification(EmailGroup.NotificationType.Exception)); }