public async Task <ActionResult <String> > AddPatient(Patient_dto Patient) { try { var Id = await _pateintService.AddPatient(Patient); return(Ok(Id)); } catch (Exception ex) { _logger.LogError(ex.Message); return(StatusCode(500)); } }
public async Task <bool> UpdatePatient(Patient_dto Patient_dto) { try { var Patient = await _context.Patients.FindAsync(Guid.Parse(Patient_dto.Id)); Patient = _mapper.Map <Patient>(Patient_dto); var dbresponse = await _context.SaveChangesAsync(); return(dbresponse == 1); } catch (Exception ex) { _logger.LogError(ex.Message); throw; } }
public async Task <string> AddPatient(Patient_dto Patient_dto) { try { Patient_dto.Id = null; Patient newPatient = _mapper.Map <Patient>(Patient_dto); _context.Patients.Add(newPatient); await _context.SaveChangesAsync(); return(_uriService.GetPatientUri(newPatient.Id.ToString()).ToString()); } catch (Exception ex) { _logger.LogError(ex.Message); throw; } }
public async Task <ActionResult <String> > UpdatePatient(Patient_dto Patient) { try { var success = await _pateintService.UpdatePatient(Patient); if (success) { return(Ok()); } return(NotFound()); } catch (Exception ex) { _logger.LogError(ex.Message); return(StatusCode(500)); } }