private async Task <IActionResult> Post(HttpRequest req) { // convert Postdata to BeaconDataModel string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); var param = JsonConvert.DeserializeObject <NotificationCreateParameter>(requestBody); if (string.IsNullOrWhiteSpace(param.Title) || string.IsNullOrWhiteSpace(param.Message)) { return(new BadRequestObjectResult("Title or Message is missing")); } var now = DateTime.UtcNow; var newNotification = new NotificationMessageModel(); newNotification.Title = param.Title; newNotification.Message = param.Message; newNotification.Created = now; newNotification.id = Guid.NewGuid().ToString("N"); var createResult = await Cosmos.Notification.CreateItemAsync(newNotification); var result = new NotificationCreateResult() { Message = createResult.Resource }; return(new OkObjectResult(result)); }
public static NotificationMessageModel GetNotificationSettingByUserIdAndType(int userId, TypeNotification type) { NotificationMessageModel data = null; try { using (var db = new NotificationMessageContext()) { data = db.Notification .Where(p => p.UserId == userId && p.Type == type) .FirstOrDefault(); if (data == null) { data = new NotificationMessageModel() { IsShow = true, Type = type }; } } } catch (Exception e) { data = new NotificationMessageModel() { IsShow = true, Type = type }; } return(data); }
public static bool AddOrUpdateNotification(NotificationMessageModel notifyData) { bool success = false; try { using (var db = new NotificationMessageContext()) { var data = db.Notification .Where(p => p.UserId == notifyData.UserId && p.Type == notifyData.Type) .FirstOrDefault(); if (data != null) { data.IsShow = notifyData.IsShow; } else { db.Notification.Add(notifyData); } success = true; db.SaveChanges(); } } catch (Exception e) { success = false; } return(success); }
internal async Task SendScanToolIssuesNotification(int requestId) { var scanToolIssueNotificationEmail = ConfigurationManager.AppSettings["ScanToolIssueNotificationEmail"]; if (!string.IsNullOrWhiteSpace(scanToolIssueNotificationEmail)) { // Load Scan Tool Issues Notification to Populate Template. var notification = await _connection.QuerySingleAsync <ScanToolIssuesNotificationModel>("EXEC Notification.usp_GetScanToolIssuesNotification @RequestId", new { RequestId = requestId }); if (notification == null) { throw new ArgumentNullException(nameof(notification)); } // Load Template. var template = await _connection.QuerySingleAsync <NotificationTemplateModel>(TemplateSql, new { TemplateName = "ScanToolIssuesEmail" }); // Populate Template. var message = new NotificationMessageModel { Destinations = new[] { new NotificationDestinationModel() { Email = scanToolIssueNotificationEmail } }, EmailSubject = Templates.ScanToolIssueTemplate(template.Subject, notification), EmailBody = Templates.ScanToolIssueTemplate(template.EmailBody, notification), TextMessage = Templates.ScanToolIssueTemplate(template.TextMessage, notification) }; // Send Message. await SendNotifications(message); } }
internal async Task SendRepairFeedbackNotification(int repairId) { var feedbackNotifications = ConfigurationManager.AppSettings["FeedbackNotifications"]; if (!string.IsNullOrWhiteSpace(feedbackNotifications)) { // Load Repair Feedback to Populate Template. var feedback = await _connection.QuerySingleAsync <RepairFeedbackNotificationModel>("EXEC Reporting.usp_GetFeedbackReport @RepairId", new { RepairId = repairId }); if (feedback == null) { throw new ArgumentNullException(nameof(feedback)); } // Load Template. var template = await _connection.QuerySingleAsync <NotificationTemplateModel>(TemplateSql, new { TemplateName = "RepairFeedbackEmail" }); // Populate Template. var message = new NotificationMessageModel { Destinations = new[] { new NotificationDestinationModel() { Email = feedbackNotifications } }, EmailSubject = Templates.RepairFeedbackTemplate(template.Subject, feedback), EmailBody = Templates.RepairFeedbackTemplate(template.EmailBody, feedback), TextMessage = Templates.RepairFeedbackTemplate(template.TextMessage, feedback) }; // Send Message. await SendNotifications(message); } }
internal async Task SendRegistrationWelcomeNotification(int registrationShopId) { var welcome = await _connection.QuerySingleAsync <RegistrationWelcomeNotificationModel>("EXEC Notification.usp_GetRegistrationWelcomeNotification @RegistrationShopId", new { RegistrationShopId = registrationShopId }); if (welcome == null) { throw new ArgumentNullException(nameof(welcome)); } // Load Template. var template = await _connection.QuerySingleAsync <NotificationTemplateModel>(TemplateSql, new { TemplateName = "RegistrationWelcomeEmail" }); // Populate Template. var message = new NotificationMessageModel { Destinations = new[] { new NotificationDestinationModel() { Email = welcome.Email } }, EmailSubject = Templates.RegistrationWelcomeTemplate(template.Subject, welcome), EmailBody = Templates.RegistrationWelcomeTemplate(template.EmailBody, welcome), TextMessage = Templates.RegistrationWelcomeTemplate(template.TextMessage, welcome) }; // Send Message. await SendNotifications(message); }
public void PropertiesTest() { // preparation var model = new NotificationMessageModel(); // model property access Helper.ModelTestHelper.PropetiesTest(model); }
internal async Task SendShopStatementNotification(int paymentId) { // Load Repair to Populate Template. var request = await _connection.QuerySingleAsync <StatementNotificationModel>("EXEC Notification.usp_GetStatementNotification @PaymentId", new { PaymentId = paymentId }); if (request == null) { throw new ArgumentNullException(nameof(request)); } // Load Template. var template = await _connection.QuerySingleAsync <NotificationTemplateModel>(TemplateSql, new { TemplateName = "ShopStatementEmail" }); // Load Reporting Contacts. var statementContacts = (await _contacts.GetStatementContacts(request.ShopGuid)).ToList(); // Load Distinct Timezones. var timezones = statementContacts.Select(r => r.TimeZoneInfoId).Distinct().ToArray(); // Process Report per Timezone. foreach (string timezone in timezones) { // Load Time Zone Offset. var offset = TimeZoneInfo.FindSystemTimeZoneById(timezone).GetUtcOffset(DateTimeOffset.UtcNow).ToString(); // Load Report. var report = (await _reportGenerator.GetStatementReportPdfStreamAsync(paymentId, offset)).ToBase64String(); // Create Attachment. var attachments = new List <INotificationMessageAttachment> { new NotificationMessageAttachment { Filename = $"AirProStatement-{request.PaymentId}.pdf", MimeType = "application/pdf", ContentBase64 = report } }; // Populate Template. var message = new NotificationMessageModel { Destinations = statementContacts.Where(r => r.TimeZoneInfoId == timezone).ToArray(), EmailSubject = Templates.ShopStatementEmailTemplate(template.Subject, request), EmailBody = Templates.ShopStatementEmailTemplate(template.EmailBody, request), TextMessage = Templates.ShopStatementEmailTemplate(template.TextMessage, request), Attachments = attachments }; // Send Message. await SendNotifications(message); } }
// Billing Notification Template. internal async Task SendBillingNotification(int repairId) { // Load Settings. var billingNotificationEmail = ConfigurationManager.AppSettings["NewBillingNotifications"]; if (billingNotificationEmail == null) { throw new ArgumentNullException(nameof(billingNotificationEmail)); } // Load Repair to Populate Template. var repair = await _connection.QuerySingleAsync <RepairNotificationModel>("EXEC Notification.usp_GetRepairNotification @RepairId", new { RepairId = repairId }); if (repair == null) { throw new ArgumentNullException(nameof(repair)); } // Send Notification. if (repair.InvoicedInd && repair.InvoiceTotal > 0) { // Load Template. var template = await _connection.QuerySingleAsync <NotificationTemplateModel>(TemplateSql, new { TemplateName = "BillingEmail" }); // Load Report. var report = (await _reportGenerator.GetInvoiceReportPdfStreamAsync(repair.RepairId)).ToBase64String(); // Populate Template. var message = new NotificationMessageModel { Destinations = new[] { new NotificationDestinationModel { Email = billingNotificationEmail } }, EmailSubject = Templates.BillingEmailTemplate(template.Subject, repair), EmailBody = Templates.BillingEmailTemplate(template.EmailBody, repair), TextMessage = Templates.BillingEmailTemplate(template.TextMessage, repair), Attachments = new List <INotificationMessageAttachment> { new NotificationMessageAttachment { Filename = $"AirProInvoice-{repair.RepairId}.pdf", MimeType = "application/pdf", ContentBase64 = report } } }; // Send Message. await SendNotifications(message); } }
public JsonResult ChangeNotifySetting(NotificationMessageModel model) { var result = new JSONResult(); try { var userId = AuthWrapper.GetUserIdByLogin(User.Identity.Name); model.UserId = userId; DataWrapper.AddOrUpdateNotification(model); } catch (Exception ex) { result.SetNotSuccess(ErrorMessages.UnknownError); logger.Error("Method ChangeNotifySetting: ", ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }
// Shop Invoice Notification Template. internal async Task SendShopInvoiceNotification(int repairId) { // Load Repair to Populate Template. var repair = await _connection.QuerySingleAsync <RepairNotificationModel>("EXEC Notification.usp_GetRepairNotification @RepairId", new { RepairId = repairId }); if (repair == null) { throw new ArgumentNullException(nameof(repair)); } // Check Customer Visible. if (repair.InvoicedInd) { // Load Template. var template = await _connection.QuerySingleAsync <NotificationTemplateModel>(TemplateSql, new { TemplateName = "ShopInvoiceEmail" }); // Load Report. var attachments = new List <INotificationMessageAttachment> { new NotificationMessageAttachment { Filename = $"AirProInvoice-{repair.RepairId}.pdf", MimeType = "application/pdf", ContentBase64 = (await _reportGenerator.GetInvoiceReportPdfStreamAsync(repair.RepairId)).ToBase64String() } }; // Load Position Statements. attachments.AddRange(await LoadAttachments(UploadType.VehicleMakes, repair.VehicleMakeId.ToString())); // Populate Template. var message = new NotificationMessageModel { Destinations = await _contacts.GetBillingContacts(repair.ShopGuid), EmailSubject = Templates.ShopInvoiceEmailTemplate(template.Subject, repair), EmailBody = Templates.ShopInvoiceEmailTemplate(template.EmailBody, repair), TextMessage = Templates.ShopInvoiceEmailTemplate(template.TextMessage, repair), Attachments = attachments }; // Send Message. await SendNotifications(message); } }
// Scan Request Notification Template. internal async Task SendScanRequestNotification(int requestId) { // Load Technician Distribution. var newRepairNotification = ConfigurationManager.AppSettings["NewRepairNotifications"]; if (newRepairNotification == null) { throw new ArgumentNullException(nameof(newRepairNotification)); } // Load Scan Request. var request = await _connection.QuerySingleAsync <RequestNotificationModel>("EXEC Notification.usp_GetRequestNotification @RequestId", new { RequestId = requestId }); if (request == null) { throw new ArgumentNullException(nameof(request)); } // Load Template. var template = await _connection.QuerySingleAsync <NotificationTemplateModel>(TemplateSql, new { TemplateName = "ScanRequestEmail" }); // Populate Template. var message = new NotificationMessageModel { Destinations = new[] { new NotificationDestinationModel { Email = newRepairNotification } }, EmailSubject = Templates.ScanRequestEmailTemplate(template.Subject, request), EmailBody = Templates.ScanRequestEmailTemplate(template.EmailBody, request), TextMessage = Templates.ScanRequestEmailTemplate(template.TextMessage, request) }; // Send Message. await SendNotifications(message); }
public NotificationDetails(NotificationMessageModel notificationMessa) { BindingContext = notificationMessa; this.notificationMessa = notificationMessa; InitializeComponent(); }
async void OnHistoryTappedAsync(object sender, ItemTappedEventArgs e) { NotificationMessageModel notificationMessa = (NotificationMessageModel)e.Item; await Navigation.PushAsync(new NotificationDetaislSel(notificationMessa)); }
// Shop Report Notification Template. internal async Task SendShopReportNotification(int requestId) { // Load Repair to Populate Template. var request = await _connection.QuerySingleAsync <RequestNotificationModel>("EXEC Notification.usp_GetRequestNotification @RequestId", new { RequestId = requestId }); if (request == null) { throw new ArgumentNullException(nameof(request)); } // Check Complete Report. if (request.ReportCompletedInd) { // Load Template. var template = await _connection.QuerySingleAsync <NotificationTemplateModel>(TemplateSql, new { TemplateName = "ShopReportEmail" }); // Load Reporting Contacts. var reportingContacts = (await _contacts.GetReportingContacts(request.ShopGuid)).ToList(); // Load Distinct Timezones. var timezones = reportingContacts.Select(r => r.TimeZoneInfoId).Distinct().ToArray(); // Load Upload Attachments. var uploads = new List <INotificationMessageAttachment>(); uploads.AddRange(await LoadAttachments(UploadType.ScanRequests, request.RequestId.ToString())); uploads.AddRange(await LoadAttachments(UploadType.VehicleMakes, request.VehicleMakeId.ToString())); // Process Report per Timezone. foreach (string timezone in timezones) { // Load Time Zone Offset. var offset = TimeZoneInfo.FindSystemTimeZoneById(timezone).GetUtcOffset(DateTimeOffset.UtcNow).ToString(); // Load Report. var report = (await _reportGenerator.GetScanReportPdfStreamAsync(request.RequestId, offset)).ToBase64String(); // Create Attachment. var attachments = new List <INotificationMessageAttachment> { new NotificationMessageAttachment { Filename = $"AirProScan-{request.RequestId}.pdf", MimeType = "application/pdf", ContentBase64 = report } }; // Check Estimate Plan. if (request.EstimatePlanInd) { var estimateReport = (await _reportGenerator.GetEstimateReportPdfStreamAsync(request.RepairId, offset)).ToBase64String(); attachments.Add(new NotificationMessageAttachment { Filename = $"AirProAssessment-{request.RequestId}.pdf", MimeType = "application/pdf", ContentBase64 = estimateReport }); } // Add Upload Attachments. attachments.AddRange(uploads); // Populate Template. var message = new NotificationMessageModel { Destinations = reportingContacts.Where(r => r.TimeZoneInfoId == timezone).ToArray(), EmailSubject = Templates.ShopReportEmailTemplate(template.Subject, request), EmailBody = Templates.ShopReportEmailTemplate(template.EmailBody, request), TextMessage = Templates.ShopReportEmailTemplate(template.TextMessage, request), Attachments = attachments }; // Send Message. await SendNotifications(message); } } }
public void CreateMethod() { // action var model = new NotificationMessageModel(); }