Пример #1
0
        public void HandleEvent(InvoiceCheckoutEvent eventMessage)
        {
            var settings = _settingService.LoadSetting <SmsNotifierSettingsModel>();

            var recipients = settings.InvoiceCheckOutRecipients.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                             .Select(p => p.Trim())
                             .Where(p => !string.IsNullOrWhiteSpace(p)).ToList();

            if (settings.SendSMSToAdminOnInvoiceCheckOut && recipients.Any())
            {
                var messageText =
                    _templateEngine.CompileTemplate(settings.GetLocalized(x => x.SMSMessageForInvoiceCheckOut),
                                                    eventMessage);

                SendMessage(messageText, recipients);
            }
        }
Пример #2
0
        public virtual ActionResult GridDataSource(DataManager dm, bool seeUsersNotifications)
        {
            var query = _notificationsService.GetAsQueryable();

            query = seeUsersNotifications
                ? query.Where(p => p.UserId != null)
                : query.Where(p => p.UserId == null);

            var url        = Url.Action("Editor", "ManageUsers", new { area = "Admin" });
            var dataSource = query.Select(p => new
            {
                p.Id,
                Date = p.NotificationDate,
                p.Readed,
                p.IsMessage,
                p.UserId,
                UserEmail = p.User.Email ?? "-",
                Recipient = p.User != null
                    ? "<a href=\"javascript:PopupWindows('" + url + "', 'UserEditor', 1200, 700, { id: '" + p.UserId +
                            "' }, 'get')\">" + p.User.Email + "</a>"
                    : "Admin",
                p.MessageResourceName,
                p.MessageArguments
            });

            var result = dataSource.ApplyDataManager(dm, out var count).ToList().Select(p => new
            {
                p.Id,
                p.Date,
                p.Readed,
                p.IsMessage,
                p.UserId,
                p.UserEmail,
                p.Recipient,
                Message = p.IsMessage
                    ? p.MessageResourceName
                    : _templateEngine.CompileTemplate(_localizationService.GetResource(p.MessageResourceName),
                                                      p.MessageArguments.JsonToObject())
            });

            return(Json(dm.RequiresCounts ? new { result = result, count = count } : (object)result,
                        JsonRequestBehavior.AllowGet));
        }