public ActionResult Add([FromBody] WebhookPost webhookPost) { var webhook = Webhook.Create(tenant.Id, webhookPost.EventIds, webhookPost.PostbackUrl, webhookPost.Secret); webhooksRepository.Add(webhook); return(Ok()); }
public async Task <bool> ProcessNewCustomer(Customer newCustomer) { var emailSentOk = false; var smsSentOk = false; var webHookPost = false; var customerAccount = await _accountRepository.GetAccountAsync(newCustomer.AccountId); if (newCustomer.Email != null && customerAccount.CompanyEmail != null) { var customerEmail = new Email() { SendTo = newCustomer.Email, Message = NewCustomerMessage(customerAccount, newCustomer), Subject = NewCustomerMessageSubject(customerAccount), Sender = customerAccount.CompanyEmail, SentDateTime = System.DateTime.Now }; emailSentOk = await _notificationService.SendEmailAsync(customerEmail); } if (newCustomer.Mobile != null && customerAccount.CompanySMSSender != null) { var customerSMS = new SMS() { SendTo = newCustomer.Mobile, Sender = customerAccount.CompanySMSSender, Message = NewCustomerMessage(customerAccount, newCustomer), SentDateTime = System.DateTime.Now }; smsSentOk = await _notificationService.SendSMSAsync(customerSMS); } if (customerAccount.NewCustomerCRMWebhook != null) { var newCustomerWebhookPost = new WebhookPost() { URL = customerAccount.NewCustomerCRMWebhook, Sender = customerAccount.CompanyName, Body = JsonConvert.SerializeObject(newCustomer), PostDateTime = System.DateTime.Now }; webHookPost = await _notificationService.PostToWebhookAsync(newCustomerWebhookPost); } newCustomer.CreditAgreement = emailSentOk && smsSentOk && webHookPost; await _customerRepository.UpdateCustomerAsync(newCustomer); return(await Task.FromResult(emailSentOk && smsSentOk && webHookPost)); }
public async Task <bool> PostToWebhookAsync(WebhookPost webpost) { bool result = await _webHookPostRepository.StoreNewWebhookPostAsync(webpost); return(result); }
public async Task <bool> DeleteWebhookPost(WebhookPost WebhookPost) { _context.Remove(WebhookPost); return((await _context.SaveChangesAsync()) > 0); }
public async Task <bool> UpdateWebhookPostAsync(WebhookPost WebhookPost) { return((await _context.SaveChangesAsync()) > 0); }
public async Task <bool> StoreNewWebhookPostAsync(WebhookPost WebhookPost) { _context.WebhookPosts.Add(WebhookPost); return((await _context.SaveChangesAsync()) > 0); }