public async Task <IHttpActionResult> Delete(Guid id) { var command = new DeleteCategoryRootCommand { Id = id }; var response = await Bus.Send <DeleteCategoryRootCommand, DeleteCategoryRootCommandResponse>(command); return(Ok(response)); }
public async Task <DeleteCategoryRootCommandResponse> Handle(DeleteCategoryRootCommand command) { var categoryRoot = await _repository.FindAsync(command.Id); if (categoryRoot == null) { throw new DomainException("دسته یافت نشد"); } if (categoryRoot.SubCategories.Any()) { throw new DomainException("این دسته بندی دارای زیر دسته بندی می باشد"); } _repository.Remove(categoryRoot); return(new DeleteCategoryRootCommandResponse()); }