/// <inheritdoc/>
        public async Task <bool> SaveEmailTemplate(string applicationName, MailTemplate mailTempalte)
        {
            if (string.IsNullOrWhiteSpace(applicationName))
            {
                throw new ArgumentException("Application Name cannot be null or empty.", nameof(applicationName));
            }

            if (mailTempalte is null)
            {
                throw new ArgumentException("Mail template param should not be null.", nameof(mailTempalte));
            }

            bool response   = false;
            bool result     = false;
            var  traceprops = new Dictionary <string, string>();

            traceprops[AIConstants.Application]    = applicationName;
            traceprops[AIConstants.MailTemplateId] = mailTempalte.TemplateId;
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            this.logger.WriteCustomEvent($"{nameof(this.SaveEmailTemplate)} Started", traceprops);

            try
            {
                this.logger.TraceInformation($"Started {nameof(this.SaveEmailTemplate)} method of {nameof(MailTemplateManager)}.", traceprops);

                var mailTempalteEntity = mailTempalte.ToEntity(applicationName, this.encryptionService);
                response = await this.mailTemplateRepository.UpsertEmailTemplateEntities(mailTempalteEntity).ConfigureAwait(false);

                this.logger.TraceInformation($"Finished {nameof(this.SaveEmailTemplate)} method of {nameof(MailTemplateManager)}.", traceprops);
                result = true;
                return(true);
            }
            catch (Exception ex)
            {
                result = false;
                this.logger.WriteException(ex);
                throw; // controller methods logs this exception
            }
            finally
            {
                stopwatch.Stop();
                traceprops[AIConstants.Result] = result.ToString(CultureInfo.InvariantCulture);
                var metrics = new Dictionary <string, double>();
                metrics[AIConstants.Duration] = stopwatch.ElapsedMilliseconds;
                this.logger.WriteCustomEvent($"{nameof(this.SaveEmailTemplate)} Completed", traceprops, metrics);
            }
        }