public async Task <EmailTemplate> EditEmailTemplate(EmailTemplate emailTemplate)
        {
            if (emailTemplate == null)
            {
                throw new ArgumentNullException(nameof(emailTemplate));
            }

            if (HasPermission(Permission.ManageBulkEmails))
            {
                var userId = GetActiveUserId();
                var currentTemplate
                    = await _emailTemplateRepository.GetByIdAsync(emailTemplate.Id);

                currentTemplate.BodyHtml    = emailTemplate.BodyHtml.Trim();
                currentTemplate.BodyText    = emailTemplate.BodyText.Trim();
                currentTemplate.Description = emailTemplate.Description.Trim();
                currentTemplate.FromAddress = emailTemplate.FromAddress.Trim();
                currentTemplate.FromName    = emailTemplate.FromName.Trim();
                currentTemplate.Subject     = emailTemplate.Subject.Trim();
                return(await _emailTemplateRepository.UpdateSaveAsync(userId, currentTemplate));
            }
            else
            {
                _logger.LogError("User {UserId} doesn't have permission to edit an email template.",
                                 GetClaimId(ClaimType.UserId));
                throw new GraException("Permission denied.");
            }
        }
 public async Task <EmailTemplate> GetEmailTemplate(int emailTemplateId)
 {
     return(await _emailTemplateRepository.GetByIdAsync(emailTemplateId));
 }