//Overloaded function to display selective records based on unique id
 public static DoctorTypeEntity showData(List <DoctorTypeEntity> db, string id)
 {
     try
     {
         DoctorTypeEntity doctype = new DoctorTypeEntity();
         if (db.Count > 0)
         {
             int count = 0;
             foreach (DoctorTypeEntity data in db)
             {
                 if (data.doctorType == id)
                 {
                     doctype = data;
                     Console.WriteLine(data.doctorType + "\t" + data.description + "\n");
                     count = 1;
                     break;
                 }
             }
             if (count == 0)
             {
                 Console.WriteLine(ConsoleConstants.NoRecord);
             }
         }
         else
         {
             Console.WriteLine(ConsoleConstants.ZeroRecord);
         }
         return(doctype);
     }
     catch
     {
         throw;
     }
 }
 //Function to insert data
 public static List <DoctorTypeEntity> insertData(List <DoctorTypeEntity> db, DoctorTypeEntity e)
 {
     try
     {
         db.Add(e);
         return(db);
     }
     catch
     {
         throw;
     }
 }
Beispiel #3
0
 public static Db CRUD_Write(Db db)
 {
     try
     {
         DoctorTypeEntity e = new DoctorTypeEntity();
         Console.WriteLine(ConsoleConstants.doctortype);
         e.doctorType = Console.ReadLine();
         if (db.doctortype.Count > 0)
         {
             //Validation - Check whether the id is already present or not. If present ask for a different id
             e.doctorType = HelperModule.validateId(e.doctorType, db.doctortype);
         }
         Console.WriteLine(ConsoleConstants.doctortypedescription);
         e.description = Console.ReadLine();
         db.doctortype = DAL.insertData(db.doctortype, e);
         return(db);
     }
     catch
     {
         throw;
     }
 }