public async Task <bool> SendOffer(Offer offer) { // get supplier email form identity server by (offer.SuplierId) var supplierEmail = "*****@*****.**";// test data var emailModel = new Models.EmailModel { To = new List <string> { supplierEmail }, Subject = configuration.GetSection("Email:SendOffer:subject").Value, Body = string.Format( configuration.GetSection("Email:SendOffer:body").Value, offer.OfferId) }; // get supplier mobile number form identity server by (offer.SuplierId) var supplierMobile = "0511111111";// test data var smsModel = new Models.SmsModel { To = new List <string> { supplierMobile }, Body = string.Format( configuration.GetSection("SMS:SendOffer").Value, offer.OfferId) }; var task1 = await _notification.SendEmail(emailModel); var task2 = await _notification.SendSms(smsModel); return(task1 == true && task1 == true); }
public static IEnumerable <MessageModel> SearchCache(string subPath) { var basePath = Path.Combine(Properties.Settings.Default.MailDir, subPath); foreach (var messagePath in messageCache.Keys) { var smsModel = new Models.SmsModel(messagePath); if (messagePath == Path.Combine(basePath, smsModel.MessageId)) { yield return(smsModel); } } }
public IActionResult Sms(Models.SmsModel sendSmsModel) { if (ModelState.IsValid) { try { var VONAGE_API_KEY = Configuration["VONAGE_API_KEY"]; var VONAGE_API_SECRET = Configuration["VONAGE_API_SECRET"]; var credentials = Credentials.FromApiKeyAndSecret(VONAGE_API_KEY, VONAGE_API_SECRET); var client = new SmsClient(credentials); var request = new SendSmsRequest { To = sendSmsModel.To, From = sendSmsModel.From, Text = sendSmsModel.Text }; var response = client.SendAnSms(request); ViewBag.MessageId = response.Messages[0].MessageId; } catch (VonageSmsResponseException ex) { ViewBag.Error = ex.Message; } } return(View("Index")); }