//Overloaded function to display selective doctor records based on unique id public static DoctorEntity showData(List <DoctorEntity> db, int id) { try { DoctorEntity doc = new DoctorEntity(); if (db.Count > 0) { int count = 0; foreach (DoctorEntity data in db) { if (data.dId == id) { doc = data; Console.WriteLine(data.dId.ToString() + "\t" + data.doctorType + "\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(doc); } catch { throw; } }
public static Db CRUD_Write(Db db) { try { DoctorEntity e = new DoctorEntity(); PersonEntity pe = new PersonEntity(); Console.WriteLine(ConsoleConstants.doctorid); e.dId = Convert.ToInt32(Console.ReadLine()); if (db.doctor.Count > 0) { //Validation- Check where any record with this id is already present or not. If present, ask different id e.dId = HelperModule.validateId(e.dId, db.doctor); } Console.WriteLine(ConsoleConstants.doctorname); 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.doctortype); e.doctorType = Console.ReadLine(); e.personEntity = pe; db.doctor = DAL.insertData(db.doctor, e); return(db); } catch { throw; } }
//Function to insert data in Doctor table public static List <DoctorEntity> insertData(List <DoctorEntity> db, DoctorEntity e) { try { db.Add(e); return(db); } catch { throw; } }