public async Task <Detalle> Handle(GetDetalleQuery request, CancellationToken cancellationToken) { if (request.DetalleId <= 0) { throw new ArgumentException(nameof(request.DetalleId)); } return(await _detalleRepository.FindByIdAsync(request.DetalleId)); }
public async Task <Response <Detalle> > Handle(DeleteDetalleCommand request, CancellationToken cancellationToken) { var cliente = await _repository.FindByIdAsync(request.Id); if (cliente == null) { return(new Response <Detalle>("Detalle No Encontrada.")); } _repository.Delete(cliente); await _unitOfWork.CompleteAsync(); return(new Response <Detalle>(cliente)); }
public async Task <Response <Detalle> > Handle(UpdateDetalleCommand request, CancellationToken cancellationToken) { var detalle = await _repository.FindByIdAsync(request.Id); if (detalle == null) { return(new Response <Detalle>("Detalle No Encontrada.")); } detalle.IdFactura = request.IdFactura; detalle.IdProducto = request.IdProducto; detalle.Precio = request.Precio; detalle.Cantidad = request.Cantidad; _repository.Update(detalle); await _unitOfWork.CompleteAsync(); return(new Response <Detalle>(detalle)); }