public void Update(string id, NoteDto noteDto) { if (noteDto is null) { throw new ArgumentNullException(nameof(NoteDto)); } var note = noteDto.Adapt <Note>(); _noteRepository.Update(id, note); }
public async Task <string> Create(NoteDto noteDto) { if (noteDto is null) { throw new ArgumentNullException(nameof(NoteDto)); } var validationResult = await _noteValidator.ValidateAsync(noteDto); if (validationResult.IsValid is false) { throw new ValidationException(validationResult.ToString(), validationResult.Errors); } bool patient = await _patientService.Get(noteDto.PatientId); if (patient is false) { throw new KeyNotFoundException($"{noteDto.PatientId}"); } var note = noteDto.Adapt <Note>(); return(_noteRepository.Create(note)); }