public PatientDataResponse updatePatient(PatientUpdateRequest request) { using (var context = new HackathonEntities()) { var user = context.users.FirstOrDefault(x => x.id == request.userId); user.first_name = request.firstName; user.last_name = request.lastName; user.email = request.email; var patient = context.Patients.FirstOrDefault(x => x.UserId == request.userId); patient.Gender = request.Gender; patient.DOB = DateTime.Parse(request.DOB); context.SaveChanges(); context.Dispose(); return(getAllPatientData(request.email)); } }
public async Task <ApiResponse> Update(Guid id, [FromBody] PatientUpdateRequest request) { try { var result = await _objControllerHelper.Update(id, request); if (result.Status == PatientUpdateStatus.Success) { return(new ApiResponse("The record has been updated successfully")); } return(new ApiResponse(404, result.Error) { StatusCode = 404, Message = "Record not found" }); } catch (Exception ex) { throw new ApiException(ex); } }
public async Task <ResultDto <Guid, PatientUpdateStatus> > Update(Guid id, PatientUpdateRequest request) { var model = _mapper.Map <PatientUpdateRequest, Patient>(request); model.Id = id; try { var result = await _repository.Update(model); return(result); } catch (DbUpdateConcurrencyException) { return(new ResultDto <Guid, PatientUpdateStatus>(PatientUpdateStatus.InternalServerError)); } catch (Exception ex) { return(new ResultDto <Guid, PatientUpdateStatus>(PatientUpdateStatus.InternalServerError)); } }
public PatientDataResponse UpdatePatient(PatientUpdateRequest request) { return(patientRepository.updatePatient(request)); }