public async Task <IActionResult> UpdatePatientAllergy(Guid uid, Guid uidAllergy, [FromBody] PatientAllergyViewModel patientAllergy) { if (!this.ModelState.IsValid) { return(this.BadRequest("Bad data")); } // Save to the database PatientAllergy results = this.unitOfWork.Patients.GetPatientAllergy(uid, uidAllergy); if (results == null || results.Id.Equals(Guid.Empty)) { return(this.BadRequest("User does not exist")); } if (!string.IsNullOrWhiteSpace(patientAllergy.Note)) { results.Note = patientAllergy.Note; } if (patientAllergy.LastOcurrence != DateTime.MinValue) { results.LastOcurrence = patientAllergy.LastOcurrence; } if (patientAllergy.AssertedDate != DateTime.MinValue) { results.AssertedDate = patientAllergy.AssertedDate; } this.unitOfWork.Patients.UpdatePatientAllergy(results); return(this.Ok(this.mapper.Map <PatientAllergyViewModel>(results))); }
public async Task <IActionResult> CreatePatientAllergy([FromBody] PatientAllergyViewModel patientAllergy, Guid uid) { if (!this.ModelState.IsValid) { return(this.BadRequest("Bad data")); } try { // Save to the database patientAllergy.IdPatient = uid; patientAllergy.Id = Guid.NewGuid(); return(this.Ok(patientAllergy)); } catch (Exception ex) { this.logger.LogError($"Failed to create the patient: {ex}"); return(this.BadRequest("Error Occurred")); } }