public PatientVM() { PatientM = new PatientModel(); Command = new PatientCommand(this); try { PatientIds = new ObservableCollection <string>(PatientM.GetAllPatientsId()); } catch (Exception e) { (App.Current as App).navigation.MainWindows.comments.Text = e.Message.ToString(); } }
public async Task <ActionResult <Patient> > Put([FromBody] PatientCommand patientCommand) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } Patient patient = _mapper.Map <PatientCommand, Patient>(patientCommand); var newPatient = await _patientService.UpdateAsync <PatientValidator>(patient); if (newPatient == null) { return(CustomResponse()); } return(Ok(_mapper.Map <Patient, PatientDTO>(newPatient))); }
public async Task <IActionResult> Post([FromBody] PatientCommand patientCommand) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } Patient patient = _mapper.Map <PatientCommand, Patient>(patientCommand); var newPatient = await _patientService.SaveAsync <PatientValidator>(patient); if (newPatient == null) { return(CustomResponse()); } return(CreatedAtAction(nameof(Post), new { id = newPatient.Id }, _mapper.Map <Patient, PatientDTO>(newPatient))); }
public IActionResult CreateNewPacijent([FromBody] PatientCommand pacijentCommand) { if (pacijentCommand != null) { Patient newPacijent = new Patient { FirstName = pacijentCommand.FirstName, LastName = pacijentCommand.LastName, LBO = pacijentCommand.LBO, Phone = pacijentCommand.Phone, Adress = pacijentCommand.Adress, Email = pacijentCommand.Email }; Card card = new Card { Patient = new Patient { FirstName = pacijentCommand.FirstName, LastName = pacijentCommand.LastName, LBO = pacijentCommand.LBO, Phone = pacijentCommand.Phone, Adress = pacijentCommand.Adress, Email = pacijentCommand.Email }, Allergens = new List <Allergen>(), Prescriptions = new List <Prescription>(), Refferals = new List <Refferal>(), Therapies = new List <Therapy>() }; _context.Cards.Add(card); _context.SaveChanges(); return(Ok(new { message = "Succesfully created patient" })); } else { return(BadRequest()); } }