public async Task ResendFailNotification() { var notifications = (await _iNotificationQuerie.GetNewNotification()); int count = 0; foreach (var item in notifications) { count++; if (item is NotificationSMS) { var sms = new Common.NotificationServices.Models.SmsModel(); sms.To.Add(((NotificationSMS)item).CurrentMobile); sms.Body = ((NotificationSMS)item).Content; if (await SendOneSms(sms)) { ((NotificationSMS)item).Update(Enums.NotifacationStatus.Send); } else { ((NotificationSMS)item).Update(Enums.NotifacationStatus.FailedToSend); } _notifayCommands.UpdateNotifayWithOutSave(item); } if (item is NotificationEmail) { var email = new Common.NotificationServices.Models.EmailModel(); email.To.Add(((NotificationEmail)item).CurrentEmail); email.Body = ((NotificationEmail)item).Content; email.Subject = ((NotificationEmail)item).Title; if (await SendOneEmail(email)) { ((NotificationEmail)item).Update(Enums.NotifacationStatus.Send); } else { ((NotificationEmail)item).Update(Enums.NotifacationStatus.FailedToSend); } _notifayCommands.UpdateNotifayWithOutSave(item); } if (count == 100) { await _notifayCommands.SaveChangesAsync(); count = 0; } } await _notifayCommands.SaveChangesAsync(); }
public async Task <bool> SendApproveJoiningRequestByEmail(List <string> suppliersEmails, string TenderNumber) { // get supplier email form identity server by (offer.SuplierId) Models.EmailModel emailModel = new Models.EmailModel(); var monafasatUrl = "(https://monafasat.etimad.sa)"; Dictionary <string, string> dic = new Dictionary <string, string>(); foreach (var item in suppliersEmails) { dic.Add(item, string.Format(_configuration.GetSection("ApproveJoiningSupplierOnTender:SendInvitationByEmail:body").Value, TenderNumber, monafasatUrl)); emailModel.Subject = string.Format(string.Format(_configuration.GetSection("ApproveJoiningSupplierOnTender:SendInvitationByEmail:subject").Value, TenderNumber)); } ; emailModel.ListOfEmails = dic; return(await _notification.SendEmail(emailModel)); }
public async Task <bool> SendInvitationByEmailToSuppliers(List <SupplierInvitationModel> suppliers, Tender tender) { Models.EmailModel emailModel = new Models.EmailModel(); Dictionary <string, string> dic = new Dictionary <string, string>(); foreach (var item in suppliers) { foreach (var email in item.SupplierContactOfficersEmails) { dic.Add(email, string.Format( _configuration.GetSection("SupplierInvitation:SendInvitation:body").Value, item.SupplierName, tender.TenderNumber)); emailModel.Subject = string.Format(_configuration.GetSection("SupplierInvitation:SendInvitation:subject").Value, tender.TenderName); } } emailModel.ListOfEmails = dic; return(await _notification.SendEmail(emailModel)); }