public async Task <IActionResult> PutPrescription(int id, PrescriptionDTO prescription) { if (id != prescription.Id) { return(BadRequest()); } var pres = await _context.Prescriptions.FirstOrDefaultAsync(p => p.Id == id); pres.medicationId = prescription.Medication.Id; pres.patientId = prescription.Patient.Id; pres.dose = prescription.Dose; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PrescriptionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <PrescriptionDTO> > DeletePrescription(int id) { var prescription = await _context.Prescriptions.FindAsync(id); if (prescription == null) { return(NotFound()); } var dto = new PrescriptionDTO { Dose = prescription.dose, Medication = new MedicationDTO { Id = prescription.medicationId, Name = prescription.medication.name }, Id = id, Patient = new PatientDTO { FamilyName = prescription.patient.familyName, GivenName = prescription.patient.firstName, Id = prescription.patientId, } }; _context.Prescriptions.Remove(prescription); await _context.SaveChangesAsync(); return(dto); }
public async Task <ActionResult <PrescriptionDTO> > GetPrescription(int id) { var pres = await _context.Prescriptions .Include(p => p.patient.FullName) .Include(p => p.medication.name) .FirstOrDefaultAsync(p => p.Id == id); if (pres == null) { return(NotFound()); } var prescription = new PrescriptionDTO { Dose = pres.dose, Id = pres.Id, Medication = new MedicationDTO { Id = pres.medicationId, Name = pres.medication.name }, Patient = new PatientDTO { FamilyName = pres.patient.familyName, GivenName = pres.patient.firstName, Id = pres.patientId } }; return(prescription); }
public int insertCorePrescription(PrescriptionDTO newPrescription) { int flagInsert = new PRESCRIPTIONTableAdapter().insertPrescriptionQuery( newPrescription.IdPatient, newPrescription.ConclusionMedical, newPrescription.Price, newPrescription.DayTime ); return(flagInsert); }
public update_prescription_ui(PrescriptionDTO _prescriptionState) { this.prescriptionState = _prescriptionState; InitializeComponent(); // ignore auto generate columns dgvDelPrescription.AutoGenerateColumns = false; dgvDelPrescription.AllowUserToAddRows = false; dgvBackup.AutoGenerateColumns = false; dgvBackup.AllowUserToAddRows = false; }
public int updateCorePrescription(PrescriptionDTO originalPrescription) { int flagUpdate = new PRESCRIPTIONTableAdapter().updatePrescriptionQuery( originalPrescription.IdPatient, originalPrescription.ConclusionMedical, originalPrescription.Price, originalPrescription.DayTime, originalPrescription.IdPrescription ); return(flagUpdate); }
private void AddLek(object sender, RoutedEventArgs e) { PrescriptionDTO prescriptionDTO = new PrescriptionDTO(Amount, Freq.ToString(), "opis", new MedicineDTO(ComboBox12.SelectedIndex + 1, TartgetRosource, "", "", 1, "", "", true), DateTime.Now, LoggedInPatient); app.PrescriptionController.Save(prescriptionDTO); PecepiesList.ItemsSource = app.PrescriptionController.GetAll(); Medicine_toAdd.Visibility = Visibility.Hidden; NumberTextBox.Visibility = Visibility.Hidden; NumberTextBox_Copy.Visibility = Visibility.Hidden; Kol_med.Visibility = Visibility.Hidden; Uc_med.Visibility = Visibility.Hidden; AddMediciniToList.Visibility = Visibility.Hidden; }
public async Task <ActionResult <PrescriptionDTO> > PostPrescription(PrescriptionDTO prescription) { var dbPres = new Prescription { dose = prescription.Dose, patientId = prescription.Patient.Id, medicationId = prescription.Medication.Id }; _context.Prescriptions.Add(dbPres); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPrescription", new { id = dbPres.Id }, prescription)); }
public async Task <bool> UpdatePrescription(PrescriptionDTO prescription) { try { await _prescriptionsClient.PutPrescriptionAsync(prescription.Id, prescription); return(true); } catch (Exception ex) { Debug.WriteLine("Couldn't update prescription"); Debug.WriteLine(ex.Message); return(false); } }
public async Task <int> AddPrescription(PrescriptionDTO prescription) { try { var result = await _prescriptionsClient.PostPrescriptionAsync(prescription); return(result.Id); } catch (Exception ex) { Debug.WriteLine("Couldn't add prescription"); Debug.WriteLine(ex.Message); return(0); } }
public int insertPrescription( string idPatient, string conclusionMedical, string price, string xtime) { PrescriptionDTO currentPrescriptionDatarow = new PrescriptionDTO(); currentPrescriptionDatarow.IdPatient = Convert.ToInt32(idPatient); currentPrescriptionDatarow.ConclusionMedical = Convert.ToString(conclusionMedical); currentPrescriptionDatarow.Price = Convert.ToDecimal(price); currentPrescriptionDatarow.DayTime = Convert.ToDateTime(xtime); return(prescriptionDal.insertCorePrescription(currentPrescriptionDatarow)); }
public PrescriptionViewModel Map(PrescriptionDTO Prescription) => _mapper.Map <PrescriptionViewModel>(Prescription);