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; } }
//Function to updata data rows public static List <PatientEntity> updateData(List <PatientEntity> db, int id) { try { int count = 0; foreach (PatientEntity de in db) { //Search for specific data row if (de.pId == id) { //Validate user input for each column/elements. //If user does not provide input for a column, existing/old data will be preserved for that column //If user provided any input for that column, new data will be over written in the column Console.WriteLine(ConsoleConstants.genericUpdate); Console.WriteLine(ConsoleConstants.patientname); de.personEntity.name = HelperModule.validateUpdate(Console.ReadLine(), de.personEntity.name); Console.WriteLine(ConsoleConstants.gender); de.personEntity.gender = HelperModule.validateUpdate(Console.ReadLine(), de.personEntity.gender); Console.WriteLine(ConsoleConstants.address); de.personEntity.address = HelperModule.validateUpdate(Console.ReadLine(), de.personEntity.address); Console.WriteLine(ConsoleConstants.email); de.personEntity.email = HelperModule.validateUpdate(Console.ReadLine(), de.personEntity.email); Console.WriteLine(ConsoleConstants.doctorid); de.doctorId = HelperModule.validateUpdate(Console.ReadLine(), de.doctorId); count = 1; break; } } if (count == 0) { Console.WriteLine(ConsoleConstants.NoRecord); } return(db); } catch { throw; } }
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; } }