Exemplo n.º 1
0
        public IHttpActionResult Delete([FromBody] int id)
        {
            try
            {
                return(Content(HttpStatusCode.OK, _patientManager.Delete(new int[] { id })));
            }

            catch (Exception ex)
            {
                return(Content(HttpStatusCode.InternalServerError, ex.Message));
            }
            // TODO: Put connection string in web config. Done
            // TODO: Change exceptions code. Done
        }
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (LvPatients.SelectedItems.Count > 0)
            {
                if (MessageBox.Show("Are you sure you want to delete data?",
                                    "Delete Verification",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    var patientsToBeDeleted = new List <int>();

                    LvPatients.SelectedItems.Cast <ListViewItem>().ToList().ForEach(x => patientsToBeDeleted.Add(int.Parse(x.SubItems[0].Text)));

                    MessageBox.Show(_patientManager.Delete(patientsToBeDeleted) ? "Patient/s deletion successful." : "Patient/s deletion failed.");
                }
            }

            DisplayDataInListView(_patientManager.Search(RetrieveDataFromFilters()));
        }
Exemplo n.º 3
0
        private void BtnDeletePatient_Click(object sender, EventArgs e)
        {
            if (LvPatients.SelectedItems.Count > 0)
            {
                List <Patient> patientList = new List <Patient>();

                foreach (ListViewItem patient in LvPatients.SelectedItems)
                {
                    patientList.Add(new Patient()
                    {
                        Surname            = patient.SubItems[0].Text,
                        FirstName          = patient.SubItems[1].Text,
                        Gender             = patient.SubItems[2].Text,
                        DateOfConsultation = DateTime.Parse(patient.SubItems[3].Text),
                        Diagnosis          = patient.SubItems[4].Text
                    });
                }

                MessageBox.Show(_manager.Delete(patientList) ? "Patient/s deletion successful." : "Patient/s deletion failed.");
            }

            DisplayDataInListView(_manager.Search(RetrieveDataFromFilters()));
        }