Esempio n. 1
0
        public async Task <IActionResult> DeleteReferenceBook(int id)
        {
            var command = new DeleteReferenceBookCommand(id);
            var result  = await _mediator.Send(command);

            return(Ok(result));
        }
Esempio n. 2
0
        public async Task <ReferenceBookDTO> Handle(DeleteReferenceBookCommand request, CancellationToken cancellationToken)
        {
            var referenceBook = await _unitOfWork.GetRepository <ReferenceBook>().FindAsync(request.Id);

            var category = await _unitOfWork.GetRepository <Category>().FindAsync(referenceBook.categoryId);

            referenceBook.Category = category;
            _unitOfWork.GetRepository <ReferenceBook>().Delete(referenceBook);
            _unitOfWork.SaveChanges();
            return(_mapper.Map <ReferenceBookDTO>(referenceBook));
        }