public async Task DeleteVisitAsync(int id) { if (id <= 0) { throw new ArgumentException(nameof(id), "Visit's id <= 0"); } var visit = await _visitRepository.GetVisitByIdAsync(id); if (visit == null) { throw new NotFoundException($"Visit with id = {id} isn't found"); } _visitRepository.DeleteVisit(visit); await _visitRepository.SaveAsync(); }
public async Task <Visit> Handle(GetVisitByIdQuery request, CancellationToken cancellationToken) { return(await _visitRepository.GetVisitByIdAsync(request.Id, cancellationToken)); }