Example #1
0
        public void Execute(Message message)
        {
            if (message == null)
            {
                return;
            }

            // in parameters
            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(Parameters.BusinessId, message.BusinessId),
                DbHelper.CreateParameter(Parameters.NotifyAfter, message.NotifyAfter),
                DbHelper.CreateParameter(Parameters.Reference, message.Reference),
                DbHelper.CreateParameter(Parameters.MessageTypeCode, message.MessageTypeEnum.GetCode()),
                DbHelper.CreateParameter(Parameters.MessageStatusCode, message.MessageStatusEnum.GetCode()),
                DbHelper.CreateParameter(Parameters.Content, message.Content),
                DbHelper.CreateParameter(Parameters.ContentTypeCode, message.ContentTypeEnum.GetCode())
            };

            Auditing.AuditFieldsHelper.PopulateAuditFields(parameters);

            DbHelper.ExecuteNonQueryCommand(this, parameters);
        }
Example #2
0
        /// <summary>
        /// Add a notification to a booking
        /// </summary>
        /// <param name="businessId">Business for booking</param>
        /// <param name="booking">Booking to create the notification for</param>
        /// <param name="cultureCode">Culture for translating</param>
        /// <param name="type">Booking Type</param>
        /// <param name="notificationDate">The datetime at which this notification should be presented to the user</param>
        /// <param name="parameters">string.format() parameters to be included in the message content</param>
        private void AddNotificationMessage(long businessId, Model.Booking.Booking booking, string cultureCode, MessageTypeEnum type, DateTime notificationDate, params object[] parameters)
        {
            var notificationMessage = new Message
            {
                ContentTypeEnum = Model.Common.ContentTypeEnum.PlainText,
                BusinessId = businessId,
                MessageTypeEnum = type,
                MessageStatusEnum = MessageStatusEnum.Unread
            };

            var notificationKey = string.Empty;
            switch (type)
            {
                case MessageTypeEnum.PreAuth:
                    notificationKey = PREAUTH_NOTIFICATION_KEY;
                    break;
                case MessageTypeEnum.CollectPayOnArrival:
                    notificationKey = COLLECTPOA_NOTIFICATION_KEY;
                    break;
                case MessageTypeEnum.BookingWithExtras:
                    notificationKey = EXTRAS_NOTIFICATION_KEY;
                    break;
            }

            // get message text
            var items = dictionaryManager.GetDictionaryItemByKeysAndCultures(new List<string> { notificationKey }, null);
            if (items != null &&
                items.Any())
            {
                ICollection<DictionaryInstance> instances = items.First().DictionaryInstances;
                notificationMessage.Content = dictionaryManager.DictionaryInstanceToContentByCulture(instances,
                                                                           cultureCode);

                // if content isn't empty
                if (!string.IsNullOrWhiteSpace(notificationMessage.Content))
                {
                    // format the text
                    notificationMessage.Content = string.Format(notificationMessage.Content, parameters);
                }
            }

            // booking id for now
            notificationMessage.Reference = booking.Id.HasValue ? booking.Id.Value.ToString() : string.Empty;

            notificationMessage.NotifyAfter = notificationDate;

            messageDao.AddMessage(notificationMessage);
        }
Example #3
0
 /// <summary>
 /// Add message to db with given information
 /// </summary>
 /// <param name="message">notification message to add</param>
 public void AddMessage(Message message)
 {
     new StoredProcedures.Notification.InsertMessageMapper().Execute(message);
 }