Beispiel #1
0
        public async Task <string> GetTemplate(
            MessageTemplateName name,
            CultureInfo culture,
            MessageTemplateType type,
            int environmentId)
        {
            const string query = @"
SELECT [Id]
      ,[Description]
      ,[Type]
      ,[Locale]
      ,[Name]
      ,[Template]
      ,[EnvironmentId]
  FROM [dom].[Message]
where [Name] = @Name
  and [Type] = @Type
  and [EnvironmentId] = @EnvironmentId
order by [Locale]
";

            using (var con = _connectionProvider.Connection)
            {
                var templates = await con.QueryAsync <MessageTemplate>(query,
                                                                       new
                {
                    Name          = name.ToString(),
                    Type          = type.ToString(),
                    EnvironmentId = environmentId,
                });

                return(culture.GetMatchedTemplate(templates.ToArray()));
            }
        }
        public async Task <string> GetTemplate(
            MessageTemplateName name,
            CultureInfo culture,
            MessageTemplateType type,
            int environmentId)
        {
            const string query = @"
select ""Id"", ""Description"", ""Type"", ""Locale"", ""Name"", ""Template"", ""EnvironmentId""
from dom.""Message""
where ""Name"" = @Name
  and ""Type"" = @Type
  and ""EnvironmentId"" = @EnvironmentId
order by ""Locale""
";

            using (var con = _connectionProvider.Connection)
            {
                var templates = await con.QueryAsync <MessageTemplate>(query,
                                                                       new
                {
                    Name          = name.ToString(),
                    Type          = type.ToString(),
                    EnvironmentId = environmentId,
                });

                return(culture.GetMatchedTemplate(templates.ToArray()));
            }
        }
Beispiel #3
0
        public async Task <string> Build(
            MessageTemplateName templateName,
            MessageTemplateType templateType,
            params object[] args)
        {
            var currentEnvironment = await environment.LoadEnvironment();

            var messageTemplate = await templateRepository.GetTemplate(
                templateName,
                cultureContext.Culture,
                templateType,
                currentEnvironment.Id.Value);

            var message = string.Format(messageTemplate, args);

            return(message);
        }