/// <summary>
        /// Prepare queued email model
        /// </summary>
        /// <param name="model">Queued email model</param>
        /// <param name="queuedEmail">Queued email</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Queued email model</returns>
        public virtual QueuedEmailModel PrepareQueuedEmailModel(QueuedEmailModel model, QueuedEmail queuedEmail, bool excludeProperties = false)
        {
            if (queuedEmail == null)
            {
                return(model);
            }

            //fill in model values from the entity
            model = model ?? queuedEmail.ToModel <QueuedEmailModel>();

            model.EmailAccountName = queuedEmail.EmailAccount?.FriendlyName ?? string.Empty;
            model.PriorityName     = _localizationService.GetLocalizedEnum(queuedEmail.Priority);
            model.CreatedOn        = _dateTimeHelper.ConvertToUserTime(queuedEmail.CreatedOnUtc, DateTimeKind.Utc);

            if (queuedEmail.SentOnUtc.HasValue)
            {
                model.SentOn = _dateTimeHelper.ConvertToUserTime(queuedEmail.SentOnUtc.Value, DateTimeKind.Utc);
            }
            if (queuedEmail.DontSendBeforeDateUtc.HasValue)
            {
                model.DontSendBeforeDate = _dateTimeHelper.ConvertToUserTime(queuedEmail.DontSendBeforeDateUtc.Value, DateTimeKind.Utc);
            }
            else
            {
                model.SendImmediately = true;
            }

            return(model);
        }
        /// <summary>
        /// Prepare queued email model
        /// </summary>
        /// <param name="model">Queued email model</param>
        /// <param name="queuedEmail">Queued email</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the queued email model
        /// </returns>
        public virtual async Task <QueuedEmailModel> PrepareQueuedEmailModelAsync(QueuedEmailModel model, QueuedEmail queuedEmail, bool excludeProperties = false)
        {
            if (queuedEmail == null)
            {
                return(model);
            }

            //fill in model values from the entity
            model ??= queuedEmail.ToModel <QueuedEmailModel>();

            model.EmailAccountName = GetEmailAccountName(await _emailAccountService.GetEmailAccountByIdAsync(queuedEmail.EmailAccountId));
            model.PriorityName     = await _localizationService.GetLocalizedEnumAsync(queuedEmail.Priority);

            model.CreatedOn = await _dateTimeHelper.ConvertToUserTimeAsync(queuedEmail.CreatedOnUtc, DateTimeKind.Utc);

            if (queuedEmail.SentOnUtc.HasValue)
            {
                model.SentOn = await _dateTimeHelper.ConvertToUserTimeAsync(queuedEmail.SentOnUtc.Value, DateTimeKind.Utc);
            }
            if (queuedEmail.DontSendBeforeDateUtc.HasValue)
            {
                model.DontSendBeforeDate = await _dateTimeHelper.ConvertToUserTimeAsync(queuedEmail.DontSendBeforeDateUtc.Value, DateTimeKind.Utc);
            }
            else
            {
                model.SendImmediately = true;
            }

            return(model);
        }
        /// <summary>
        /// Prepare queued email model
        /// </summary>
        /// <param name="model">Queued email model</param>
        /// <param name="queuedEmail">Queued email</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Queued email model</returns>
        public virtual QueuedEmailModel PrepareQueuedEmailModel(QueuedEmailModel model, QueuedEmail queuedEmail, bool excludeProperties = false)
        {
            if (queuedEmail == null)
            {
                return(model);
            }

            //fill in model values from the entity
            model = model ?? queuedEmail.ToModel <QueuedEmailModel>();
            //chai
            //model.PriorityName = queuedEmail.Priority.GetLocalizedEnum(_localizationService, _workContext);
            model.PriorityName = CommonHelper.ConvertEnum(queuedEmail.Priority.ToString());
            model.CreatedOn    = _dateTimeHelper.ConvertToUserTime(queuedEmail.CreatedOnUtc, DateTimeKind.Utc);

            if (queuedEmail.SentOnUtc.HasValue)
            {
                model.SentOn = _dateTimeHelper.ConvertToUserTime(queuedEmail.SentOnUtc.Value, DateTimeKind.Utc);
            }
            if (queuedEmail.DontSendBeforeDateUtc.HasValue)
            {
                model.DontSendBeforeDate = _dateTimeHelper.ConvertToUserTime(queuedEmail.DontSendBeforeDateUtc.Value, DateTimeKind.Utc);
            }
            else
            {
                model.SendImmediately = true;
            }

            return(model);
        }
Example #4
0
        /// <summary>
        /// Prepare queued email model
        /// </summary>
        /// <param name="model">Queued email model</param>
        /// <param name="queuedEmail">Queued email</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Queued email model</returns>
        public virtual QueuedEmailModel PrepareQueuedEmailModel(QueuedEmailModel model, QueuedEmail queuedEmail, bool excludeProperties = false)
        {
            if (queuedEmail == null)
            {
                return(model);
            }

            //fill in model values from the entity
            model = model ?? queuedEmail.ToModel <QueuedEmailModel>();

            model.CreatedOn = queuedEmail.CreatedOnUtc.ToLocalTime();

            if (queuedEmail.SentOnUtc.HasValue)
            {
                model.SentOn = queuedEmail.SentOnUtc.Value.ToLocalTime();
            }

            return(model);
        }