public Task Handle(CourseCreatedEvent @event) { EnsureArg.IsNotNull(@event); var contentHolder = Domain.ContentHolder.Create(@event.Name, @event.HolderEmail, @event.Id); contentHolderRepository.Add(contentHolder); contentHolderRepository.SaveChanges(); return(Task.CompletedTask); }
protected override Result Handle(AddContentCommand request) { EnsureArg.IsNotNull(request); var contentHolder = contentHolderRepository.GetById(request.ContentHolderId); var model = request.Model; var files = fileRepository.FilesByIds(model.FilesIds); var content = Content.Create(model.Description, files); return(contentHolder.ToResult("Content holder not found!") .OnSuccess(x => x.AddContent(request.Email, content)) .OnSuccess(() => contentHolderRepository.Update(contentHolder.Value)) .OnSuccess(() => contentHolderRepository.SaveChanges()) .OnSuccess(() => eventsDispatcher.Raise(new ContentAddedEvent { ContentHolderName = contentHolder.Value.Name, OriginId = contentHolder.Value.OriginId }))); }