public async Task <bool> Handle(SaveTemplateCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(false); } var template = request.ToModel(); var templateAlreadyExist = await _templateRepository.Exist(template.Name); if (templateAlreadyExist) { await Bus.RaiseEvent(new DomainNotification("Template", "Template already exist.")); return(false); } _templateRepository.Add(template); if (await Commit()) { await Bus.RaiseEvent(new TemplateAddedEvent(template)); return(true); } return(false); }