コード例 #1
0
        public IActionResult CreatePatient(PatientViewModel viewmodel)
        {
            viewmodel.Patient.Owner = _clientrepo.GetClientById(viewmodel.Patient.Owner.Id);
            _patientrepo.CreatePatient(viewmodel.Patient);

            return(RedirectToAction("ListPatients"));
        }
コード例 #2
0
        public IActionResult CreatePatient([FromBody] PatientCreateDto patients)
        {
            if (patients == null)
            {
                return(BadRequest(ModelState));
            }

            if (_patients.PatientExists(patients.Name))
            {
                ModelState.AddModelError("", "The Patient already Exist");
                return(StatusCode(404, ModelState));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var patientObj = _mapper.Map <Patient>(patients);

            if (!_patients.CreatePatient(patientObj))
            {
                ModelState.AddModelError("", $"Something went wrong when you trying to save {patientObj.Name}");
                return(StatusCode(500, ModelState));
            }

            return(CreatedAtRoute("GetPatient", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = patientObj.Id }, patientObj));
        }
コード例 #3
0
        public PatientViewModel CreatePatient(PatientBindingModel patientBindingModel)
        {
            var model = new Patient
            {
                FirstName     = patientBindingModel.FirstName,
                LastName      = patientBindingModel.LastName,
                Login         = patientBindingModel.Login,
                Bonus         = 0,
                Password      = patientBindingModel.Password, // TODO шифровать!!!!!!!!!!!!!!!!
                PatientStatus = PatientStatus.Active,
                Phone         = patientBindingModel.Phone
            };

            _patientRepository.CreatePatient(model);

            return(new PatientViewModel
            {
                Id = model.Id,
                Login = model.Login,
                FirstName = model.FirstName,
                LastName = model.LastName,
                Bonus = model.Bonus,
                PatientStatus = model.PatientStatus.ToString(),
                Phone = model.Phone
            });
        }
コード例 #4
0
        public ActionResult <PatientsReadDto> Createpatient(PatientCreateDto patientCreateDto)
        {
            var patientModel = _mapper.Map <Patient>(patientCreateDto);

            _repository.CreatePatient(patientModel);
            _repository.SaveChanges();

            return(Ok(patientModel));
        }
コード例 #5
0
        public PatientDTO CreatePatient([FromBody] PatientDTO patient)
        {
            Patient patientEntity = _mapper.Map <Patient>(patient);

            _repository.CreatePatient(patientEntity);
            _repository.Save();
            PatientDTO newPatient = _mapper.Map <PatientDTO>(patientEntity);

            return(newPatient);
        }
コード例 #6
0
ファイル: PatientService.cs プロジェクト: charolia/csharpTest
        public void CreatePatient(PatientDto patient)
        {
            if (patient == null)
            {
                throw new ArgumentNullException(nameof(patient));
            }

            patientRepository.CreatePatient(mapper.Map <Patient>(patient));

            foreach (var immunisation in patient.Immunisations)
            {
                AddImmunisation(patient.Id, immunisation);
            }
        }
コード例 #7
0
        public IActionResult CreatePatient([FromBody] PatientCreateDTO info)
        {
            PatientDTO response = repository.CreatePatient(info);

            if (response != null)
            {
                return(new ObjectResult(response));
            }

            else
            {
                return(new BadRequestObjectResult("Try again, you missed some of the needed informations."));
            }
        }
コード例 #8
0
        public async Task <ActionResult <Patient> > CreatePatient(PatientVM newPatientVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newPatient = await _repository.CreatePatient(newPatientVM);

            if (newPatient == null)
            {
                ModelState.AddErrorMessage("Unable to create Patient");
                return(BadRequest(ModelState));
            }
            return(Ok(newPatient));
        }
コード例 #9
0
        public async Task <long> PersistPatientDetailsAsync(PatientDto patientDto)
        {
            long patientId = 0;

            if (patientDto.Patients != null)
            {
                patientId = await _patientRepository.CreatePatient(patientDto.Patients);
            }

            if (patientDto.Treatments != null)
            {
                patientDto.Treatments.PatientId = patientId;
                await _treatmentRepository.CreateTreatment(patientDto.Treatments);
            }

            return(patientId);
        }
コード例 #10
0
        /// <summary>
        /// Edit patient record
        /// </summary>
        /// <param name="viewModel">Patient record view model</param>
        /// <returns>View</returns>
        public ActionResult EditPatient(PatientViewModel viewModel)
        {
            if (viewModel == null || string.IsNullOrEmpty(viewModel.PatientId.ToString()))
            {
                TempData["errorMessage"] = "Invalid request.";
                return(RedirectToAction("List"));
            }

            if (viewModel.PatientId == 0)
            {
                var result = _patientRepository.CreatePatient(viewModel);
                TempData["successMessage"] = result ? "Patient created successfully." : "Something went wrong! Please check your inputs.";

                return(RedirectToAction("List"));
            }
            else
            {
                var result = _patientRepository.EditPatient(viewModel);
                TempData["successMessage"] = result ? "Profile updated successfully." : "Something went wrong! Please check your inputs.";

                return(RedirectToAction("Edit", new { id = viewModel.PatientId }));
            }
        }
コード例 #11
0
 public async Task <Patient> CreatePatient(Patient patient)
 {
     return(await patientRepository.CreatePatient(patient));
 }