예제 #1
0
        public IActionResult UpdatePatient([FromBody] SavePatientModel model)
        {
            if (!ModelState.IsValid)
            {
                throw new Exception(ModelState.GetErrorsMessage());
            }
            var result = _patientService.UpdatePatient(model);

            return(Json(new { success = result }));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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
            }));
        }