Example #1
0
        /// <summary>
        ///     Takes data from the view and delete it from list
        /// </summary>
        /// <param name="category"></param>
        /// <param name="choice"></param>
        /// <returns></returns>
        public bool Delete(Category category, int choice)
        {
            switch (category)
            {
            case Category.HOSPITAL:
                try
                {
                    Hospital h = findHospital(choice);
                    SuccessMsg("Hospital " + h.Name + " Deleted");
                    hospitals.Remove(h);
                }
                catch (Exception)
                {
                    ErrorMsg("Wrong ID. Hospital cannot be deleted");
                }
                break;

            case Category.DOCTOR:
                try
                {
                    Doctor d = findDoctor(choice);
                    SuccessMsg("Doctor " + d.Name + " Deleted");
                    doctors.Remove(d);
                }
                catch (Exception)
                {
                    ErrorMsg("Wrong ID. Doctor cannot be deleted");
                }
                break;

            case Category.PATIENT:
                try
                {
                    Patient p = findPatient(choice);
                    SuccessMsg("Patient " + p.Name + " Deleted");
                    patients.Remove(p);
                }
                catch (Exception)
                {
                    ErrorMsg("Wrong ID. Patient cannot be deleted");
                }
                break;

            case Category.RECORD:
                try
                {
                    PatientRecord r = findRecord(choice);
                    SuccessMsg("Record " + r.ID + " Deleted");
                    records.Remove(r);
                }
                catch (Exception)
                {
                    ErrorMsg("Wrong ID. Record cannot be deleted");
                }
                break;

            default:
                ErrorMsg("Wrong Category");
                return(false);
            }
            return(true);
        }