public static SendGridData CreateSendGridData(Email email) { SendGridData sgd = new SendGridData { personalizations = new List <RecipientGroup>(), from = new EmailCredential { email = email.From }, subject = email.Subject, content = new List <EmailContent>() }; RecipientGroup group = new RecipientGroup(); sgd.personalizations.Add(group); addRecipientGroup(group, (rg) => { rg.to = new List <EmailCredential>(); }, (rg, addr) => { rg.to.Add(new EmailCredential { email = addr }); }, email.Tos); addRecipientGroup(group, (rg) => { rg.cc = new List <EmailCredential>(); }, (rg, addr) => { rg.cc.Add(new EmailCredential { email = addr }); }, email.Ccs); addRecipientGroup(group, (rg) => { rg.bcc = new List <EmailCredential>(); }, (rg, addr) => { rg.bcc.Add(new EmailCredential { email = addr }); }, email.Bccs); sgd.content.Add(new EmailContent { type = "text/plain", value = email.Content }); return(sgd); }
/// <summary> /// Gets message groups, does not include recipients /// </summary> /// <param name="churchID">churchID</param> /// <returns></returns> public List <IRecipientGroup> GetRecipientGroups(int churchID, int messageTypeEnumId) { var proc = "GetMessageRecipientGroups"; var paramz = new List <SqlParameter>(); paramz.Add(new SqlParameter("churchId", churchID)); paramz.Add(new SqlParameter("messageTypeEnumId", messageTypeEnumId)); Func <SqlDataReader, IRecipientGroup> readFx = (reader) => { var item = new RecipientGroup(); item.Id = reader.ValueOrDefault <int>("Id"); item.ChurchId = reader.ValueOrDefault <int>("ChurchID"); item.Name = reader.ValueOrDefault <string>("Name"); item.Description = reader.ValueOrDefault <string>("Description"); item.LastMessageDate = reader.ValueOrDefault <DateTimeOffset>("LastMessageDate"); item.LastMessageBody = reader.ValueOrDefault <string>("LastMessageBody"); item.LastMessageSubject = reader.ValueOrDefault <string>("LastMessageSubject"); item.MessageTypeEnumID = reader.ValueOrDefault <int>("MessageTypeEnumID"); return(item); }; var list = this.executor.ExecuteSql <IRecipientGroup>(proc, CommandType.StoredProcedure, paramz, readFx); return(list); }
private static void addRecipientGroup(RecipientGroup rg, Action <RecipientGroup> createRecipientGroup, Action <RecipientGroup, string> addEmailCredential, string[] addressArray) { if (addressArray == null || addressArray.Length == 0) { return; } createRecipientGroup(rg); foreach (string addr in addressArray) { addEmailCredential(rg, addr); } }
public void RecipientAdd(Recipient recipient) { RecipientGroup group = this.ReportItem as RecipientGroup; if (group.RecipientList.ContainsKey(recipient.Name)) { MessageBox.Show("The same name recipient exists, cannot add."); return; } group.RecipientList.Add(recipient.Name, recipient); }
public async Task <Unit> Handle(RecipientGroupCreateCommand request, CancellationToken cancellationToken) { var currentUserId = identityService.GetCurrentUserId(); var group = new RecipientGroup { Name = request.Name, UserId = currentUserId }; context.RecipientGroups.Add(group); await context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
public void RecipientDelete(Recipient recipient) { if (recipient == null) { MessageBox.Show("Please select a recipient."); return; } if (MessageBox.Show("Do you want to delete the recipient " + recipient.Name, "Delete", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { RecipientGroup group = this.ReportItem as RecipientGroup; group.RecipientList.Remove(recipient.Name); } }
public override string ToHtml() { if (RecipientGroup.Count == 1) { if (RecipientGroup.First().Author.Count == 1 && RecipientGroup.First().Recipient.Count == 1) { if (RecipientGroup.First().Recipient.First().Equals(RecipientGroup.First().Author.First())) { // Когато авторът на електронното изявление е и титулярът, получател на електронната // административна услуга, поредността на визуализация едно под друго е string result = Resources.Visualisation.HtmlElectronicServiceApplicantSamAuthorAndRecipient; result = result.Replace( ":Recipient:", RecipientGroup.First().Recipient.First().ToString()); result = result.Replace( ":EmailAddress:", EmailAddress); return result; } else { //Авторът на изявлението се визуализира само ако е различен от получателя на електронната административна услуга. //В този случай поредността на визуализация едно под друго е: string result = Resources.Visualisation.HtmlElectronicServiceApplicantDifferentAuthorAndRecipient; result = result.Replace( ":Author:", RecipientGroup.First().Author.First().ToString()); result = result.Replace( ":Recipient:", RecipientGroup.First().Recipient.First().ToString()); result = result.Replace( ":AuthorQuality:", (string.IsNullOrEmpty(RecipientGroup.First().AuthorQuality)) ? Resources.Visualisation.EmptyAuthorQuality : RecipientGroup.First().AuthorQuality); result = result.Replace( ":EmailAddress:", EmailAddress); return result; } } //TODO: Да се допишат останалите случаи... } else if (RecipientGroup.Count > 1) { } return ""; }
private void comboBoxGroup_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.comboBoxGroup.SelectedValue != null) { RecipientGroup group = this.comboBoxGroup.SelectedValue as RecipientGroup; if (group.Name != "NotSet") { (this.ViewModel.ReportItem as ReportTask).Group = group; } else { (this.ViewModel.ReportItem as ReportTask).Group = null; } } }
protected override bool OnQvItemAdd(IReportItem qvItem) { try { RecipientGroup group = qvItem as RecipientGroup; if (string.IsNullOrWhiteSpace(group.Name) || group.RecipientList.Count == 0) { MessageBox.Show("Name and recipients are required."); return(false); } ReportConfig.RecipientGroupManager.AddItem(qvItem); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } return(true); }
public async Task <IHttpActionResult> SaveRecipientGroups(RecipientGroup recipientGroup) { var id = this.repo.SaveRecipientGroup(recipientGroup); recipientGroup.Id = id; if (string.IsNullOrEmpty(recipientGroup.Description)) { recipientGroup.Description = recipientGroup.Name; } foreach (var r in recipientGroup.Recipients) { r.MessageRecipientGroupId = recipientGroup.Id; this.repo.SaveRecipient(r); var recipient = this.repo.GetRecipient(r.ContactInfoId, recipientGroup.Id); r.Id = recipient.Id; r.Name = recipient.Name; r.Address = recipient.Address; } return(Ok(recipientGroup)); }