public async Task <TemplateKind> Get(string templateKindKey, CancellationToken cancellationToken) { Check.NotEmpty(templateKindKey, nameof(templateKindKey)); var templateKind = await _templateKindsRepository.GetTemplateKind(templateKindKey, cancellationToken); if (templateKind == null) { throw new TemplateKindNotFoundException(templateKindKey); } return(templateKind); }
public async Task SetDefaultTemplate(string templateKindKey, Guid templateId, CancellationToken cancellationToken) { Check.NotEmpty(templateKindKey, nameof(templateKindKey)); Check.GuidNotEmpty(templateId, nameof(templateId)); if (await _templateKindsRepository.GetTemplateKind(templateKindKey, cancellationToken) == null) { throw new TemplateKindNotFoundException(templateKindKey); } if (!await _templatesRepository.TemplateExists(templateId, cancellationToken)) { throw new TemplateNotFoundException(templateId); } try { await _templatesRepository.SetDefaultTemplate(templateKindKey, templateId, cancellationToken); } catch (Exception e) { throw new SetDefaultTemplateFailedException(templateKindKey, templateId, e); } }