public async Task <bool> Handle(SaveEmailCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(false); } var email = await _emailRepository.GetByType(request.Type); if (email == null) { email = request.ToModel(); _emailRepository.Add(email); } else { email.Update(request); _emailRepository.Update(email); } if (await Commit()) { await Bus.RaiseEvent(new EmailSavedEvent(email)); return(true); } return(false); }