public async Task ReplaceTemplateTextAsync(int directEmailTemplateId, int languageId, DirectEmailTemplateText emailTemplateText) { if (emailTemplateText == null) { throw new ArgumentNullException(nameof(emailTemplateText)); } var currentTemplate = await _directEmailTemplateRepository .GetWithTextByIdAsync(directEmailTemplateId, languageId); if (currentTemplate.DirectEmailTemplateText == null) { currentTemplate.DirectEmailTemplateText = new DirectEmailTemplateText { DirectEmailTemplateId = directEmailTemplateId, LanguageId = languageId }; } currentTemplate.DirectEmailTemplateText.BodyCommonMark = emailTemplateText.BodyCommonMark; currentTemplate.DirectEmailTemplateText.Footer = emailTemplateText.Footer; currentTemplate.DirectEmailTemplateText.Preview = emailTemplateText.Preview; currentTemplate.DirectEmailTemplateText.Subject = emailTemplateText.Subject; currentTemplate.DirectEmailTemplateText.Title = emailTemplateText.Title; await _directEmailTemplateRepository .UpdateSaveWithTextAsync(GetActiveUserId(), currentTemplate); await _cache.RemoveAsync(GetCacheKey(CacheKey.DirectEmailTemplateId, currentTemplate.Id, currentTemplate.DirectEmailTemplateText.LanguageId)); }
public async Task ImportSaveTextAsync(int userId, DirectEmailTemplateText directEmailTemplateText) { var dbEntity = _mapper.Map <DirectEmailTemplateText, Model.DirectEmailTemplateText>(directEmailTemplateText); dbEntity.CreatedBy = userId; dbEntity.CreatedAt = _dateTimeProvider.Now; EntityEntry <Model.DirectEmailTemplateText> dbEntityEntry = _context.Entry(dbEntity); if (dbEntityEntry.State != EntityState.Detached) { dbEntityEntry.State = EntityState.Added; } else { await _context.DirectEmailTemplateTexts.AddAsync(dbEntity); } await SaveAsync(); }