Пример #1
0
 //Overloaded function to display selective records based on unique id
 public static PatientEntity showData(List <PatientEntity> db, int id)
 {
     try
     {
         PatientEntity patiententity = new PatientEntity();
         if (db.Count > 0)
         {
             int count = 0;
             foreach (PatientEntity data in db)
             {
                 if (data.pId == id)
                 {
                     patiententity = data;
                     Console.WriteLine(data.pId.ToString() + "\t" + data.doctorId.ToString() + "\t" + data.personEntity.name + "\t" + data.personEntity.email + "\t" + data.personEntity.address + "\t" + data.personEntity.gender + "\n");
                     count = 1;
                     break;
                 }
             }
             if (count == 0)
             {
                 Console.WriteLine(ConsoleConstants.NoRecord);
             }
         }
         else
         {
             Console.WriteLine(ConsoleConstants.ZeroRecord);
         }
         return(patiententity);
     }
     catch
     {
         throw;
     }
 }
 public static Db CRUD_Write(Db db)
 {
     try
     {
         PatientEntity e  = new PatientEntity();
         PersonEntity  pe = new PersonEntity();
         Console.WriteLine(ConsoleConstants.patientid);
         e.pId = Convert.ToInt32(Console.ReadLine());
         if (db.patient.Count > 0)
         {
             //Validation- Check where any record with this id is already present or not. If present, ask different id
             e.pId = HelperModule.validateId(e.pId, db.patient);
         }
         Console.WriteLine(ConsoleConstants.patientname);
         pe.name = Console.ReadLine();
         Console.WriteLine(ConsoleConstants.gender);
         pe.gender = Console.ReadLine();
         Console.WriteLine(ConsoleConstants.address);
         pe.address = Console.ReadLine();
         Console.WriteLine(ConsoleConstants.email);
         pe.email = Console.ReadLine();
         Console.WriteLine(ConsoleConstants.doctorid);
         e.doctorId     = Convert.ToInt32(Console.ReadLine());
         e.personEntity = pe;
         db.patient     = DAL.insertData(db.patient, e);
         return(db);
     }
     catch
     {
         throw;
     }
 }
Пример #3
0
 //Function to insert data
 public static List <PatientEntity> insertData(List <PatientEntity> db, PatientEntity e)
 {
     try
     {
         db.Add(e);
         return(db);
     }
     catch
     {
         throw;
     }
 }