コード例 #1
0
 public Task<Patient> UpdatePatientAsync(Patient patient)
 {
     return Task.Run(() =>
     {
         if (string.IsNullOrEmpty(patient.Id)) patient.Id = Guid.NewGuid().ToString();
         _dbContext.Patients.AddOrUpdate(patient);
         return patient;
     });
 }
コード例 #2
0
 public Task<Patient> CreatePatientAsync(Patient patient)
 {
     return Task.Run(() =>
     {
         patient.Id = Guid.NewGuid().ToString();
         _dbContext.Patients.Add(patient);
         return patient;
     });
 }
コード例 #3
0
 public async Task<IHttpActionResult> PutPatient(Patient patient)
 {
     try
     {
         if (string.IsNullOrEmpty(patient?.Id)) return BadRequest();
         Patient retPatient = await _repository.UpdatePatientAsync(patient);
         if (retPatient == null) return BadRequest();
         return Ok(retPatient);
     }
     catch (Exception exception)
     {
         this.Logger.LogError(exception.ToString());
         return InternalServerError();
     }
 }
コード例 #4
0
 public async Task<IHttpActionResult> PostPatient(Patient patient)
 {
     try
     {
         if (patient == null) return BadRequest();
         Patient retPatent = await _repository.CreatePatientAsync(patient);
         if (retPatent == null) return BadRequest();
         return Created("", retPatent);
     }
     catch (Exception exception)
     {
         this.Logger.LogError(exception.ToString());
         return InternalServerError();
     }
 }