public IActionResult UpdatePatient([FromBody] SavePatientModel model) { if (!ModelState.IsValid) { throw new Exception(ModelState.GetErrorsMessage()); } var result = _patientService.UpdatePatient(model); return(Json(new { success = result })); }
public bool UpdatePatient(SavePatientModel model) { if (string.IsNullOrEmpty(model.PatientId)) { throw new ServiceException("PatientId field cannot be empty"); } var exist = _patientRepository.FindById(model.PatientId); if (exist == null) { throw new ServiceException("Patient not exist"); } exist.Firstname = model.Firstname; exist.Lastname = model.Lastname; exist.Birthday = model.Birthday; exist.Gender = model.Gender; exist.Phone = model.Phone; exist.Address = model.Address; exist.Status = model.Status; return(_patientRepository.Update(exist)); }
public bool AddPatient(SavePatientModel model) { if (string.IsNullOrEmpty(model.PatientId)) { throw new ServiceException("PatientId field cannot be empty"); } var exist = _patientRepository.FindById(model.PatientId); if (exist == null) { throw new ServiceException("PatientId already exists"); } return(_patientRepository.Insert(new Patient { PatientId = model.PatientId, Firstname = model.Firstname, Lastname = model.Lastname, Birthday = model.Birthday, Gender = model.Gender, Phone = model.Phone, Address = model.Address, Status = model.Status })); }