public async Task <ValidationResult> Handle(RemoveItemCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { return(request.ValidationResult); } var item = await _showcaseRepository.GetById(request.Id); if (item is null) { AddError("The showcase cannot delete the item, because it does not exist in this showcase."); return(ValidationResult); } item.AddDomainEvent(new RemovedItemEvent(request.Id)); _showcaseRepository.Remove(item); return(await Commit(_showcaseRepository.UnitOfWork)); }
public async Task <IEnumerable <ShowcaseViewModel> > GetById(Guid id) { return(_mapper.Map <IEnumerable <ShowcaseViewModel> >(await _showcaseRepository.GetById(id))); }