public IActionResult CreatePatient(PatientViewModel viewmodel) { viewmodel.Patient.Owner = _clientrepo.GetClientById(viewmodel.Patient.Owner.Id); _patientrepo.CreatePatient(viewmodel.Patient); return(RedirectToAction("ListPatients")); }
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)); }
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 }); }
public ActionResult <PatientsReadDto> Createpatient(PatientCreateDto patientCreateDto) { var patientModel = _mapper.Map <Patient>(patientCreateDto); _repository.CreatePatient(patientModel); _repository.SaveChanges(); return(Ok(patientModel)); }
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); }
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); } }
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.")); } }
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)); }
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); }
/// <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 })); } }
public async Task <Patient> CreatePatient(Patient patient) { return(await patientRepository.CreatePatient(patient)); }