示例#1
0
        public async Task <IActionResult> EditRecord(RecordForAddEditDetails record)
        {
            var patientToEdit = await _patientRepo.GetPatient(record.PatientId, true);

            var patientRecord = patientToEdit.Records.FirstOrDefault(rec => rec.Id == record.Id);

            if (patientRecord == null)
            {
                return(BadRequest("This record is not for this patient"));
            }

            if (!await _repo.RecordExists(record.Id))
            {
                return(BadRequest("Record does not exist"));
            }
            else if (patientToEdit == null)
            {
                return(BadRequest("Patient does not exist"));
            }
            else
            {
                var newRecord = _repo.EditRecord(_mapper.Map <Record>(record)).Result;


                return(Ok(newRecord));
            }
        }