public override T ObjectConvert <T, U>(U entity) { Doctor doctor = entity as Doctor; if (doctor == null) { return(default(T)); } BO.Doctor doctorBO = new BO.Doctor(); doctorBO.ID = doctor.Id; doctorBO.LicenseNumber = doctor.LicenseNumber; doctorBO.WCBAuthorization = doctor.WCBAuthorization; doctorBO.WcbRatingCode = doctor.WcbRatingCode; doctorBO.NPI = doctor.NPI; doctorBO.Title = doctor.Title; doctorBO.TaxType = (BO.GBEnums.TaxType)doctor.TaxTypeId; if (doctor.IsDeleted.HasValue) { doctorBO.IsDeleted = doctor.IsDeleted.Value; } if (doctor.UpdateByUserID.HasValue) { doctorBO.UpdateByUserID = doctor.UpdateByUserID.Value; } doctorBO.IsCalendarPublic = doctor.IsCalendarPublic; if (doctor.DoctorSpecialities != null) { List <BO.DoctorSpeciality> lstDoctorSpecility = new List <BO.DoctorSpeciality>(); foreach (var item in doctor.DoctorSpecialities) { if (item.IsDeleted == false) { using (DoctorSpecialityRepository sr = new DoctorSpecialityRepository(_context)) { lstDoctorSpecility.Add(sr.ObjectConvert <BO.DoctorSpeciality, DoctorSpeciality>(item)); } } } doctorBO.DoctorSpecialities = lstDoctorSpecility; } return((T)(object)doctorBO); }
public override T Convert <T, U>(U entity) { Doctor doctor = entity as Doctor; if (doctor == null) { return(default(T)); } BO.Doctor doctorBO = new BO.Doctor(); doctorBO.ID = doctor.Id; doctorBO.LicenseNumber = doctor.LicenseNumber; doctorBO.WCBAuthorization = doctor.WCBAuthorization; doctorBO.WcbRatingCode = doctor.WcbRatingCode; doctorBO.NPI = doctor.NPI; doctorBO.Title = doctor.Title; doctorBO.TaxType = (BO.GBEnums.TaxType)doctor.TaxTypeId; if (doctor.IsDeleted.HasValue) { doctorBO.IsDeleted = doctor.IsDeleted.Value; } if (doctor.UpdateByUserID.HasValue) { doctorBO.UpdateByUserID = doctor.UpdateByUserID.Value; } doctorBO.IsCalendarPublic = doctor.IsCalendarPublic; if (doctor.User != null) { if (doctor.User.IsDeleted.HasValue == false || (doctor.User.IsDeleted.HasValue == true && doctor.User.IsDeleted.Value == false)) { BO.User boUser = new BO.User(); using (UserRepository sr = new UserRepository(_context)) { boUser = sr.Convert <BO.User, User>(doctor.User); doctorBO.user = boUser; } if (doctor.DoctorSpecialities != null) { List <BO.DoctorSpeciality> lstDoctorSpecility = new List <BO.DoctorSpeciality>(); foreach (var item in doctor.DoctorSpecialities) { if (item.IsDeleted == false) { using (DoctorSpecialityRepository sr = new DoctorSpecialityRepository(_context)) { lstDoctorSpecility.Add(sr.ObjectConvert <BO.DoctorSpeciality, DoctorSpeciality>(item)); } } } doctorBO.DoctorSpecialities = lstDoctorSpecility; } if (doctor.DoctorRoomTestMappings != null) { List <BO.DoctorRoomTestMapping> lstDoctorRoomTestMapping = new List <BO.DoctorRoomTestMapping>(); foreach (var item in doctor.DoctorRoomTestMappings) { if (item.IsDeleted == false) { BO.DoctorRoomTestMapping doctorRoomTestMappingBO = new BO.DoctorRoomTestMapping(); doctorRoomTestMappingBO.ID = item.Id; doctorRoomTestMappingBO.IsDeleted = item.IsDeleted; if (doctorRoomTestMappingBO.UpdateByUserID.HasValue) { doctorRoomTestMappingBO.UpdateByUserID = item.UpdateByUserID.Value; } if (item.RoomTest != null && (item.RoomTest.IsDeleted.HasValue == false || (item.RoomTest.IsDeleted.HasValue == true && item.RoomTest.IsDeleted.Value == false))) { BO.RoomTest boRoomTest = new BO.RoomTest(); using (RoomTestRepository sr = new RoomTestRepository(_context)) { boRoomTest = sr.Convert <BO.RoomTest, RoomTest>(item.RoomTest); doctorRoomTestMappingBO.RoomTest = boRoomTest; } } lstDoctorRoomTestMapping.Add(doctorRoomTestMappingBO); } } doctorBO.DoctorRoomTestMappings = lstDoctorRoomTestMapping; } //if (doctor.User.UserCompanies != null && doctorBO.user.UserCompanies != null && doctorBO.user.UserCompanies.Count <= 0) if (doctor.User.UserCompanies != null) { List <BO.UserCompany> lstUserCompany = new List <BO.UserCompany>(); foreach (var item in doctor.User.UserCompanies) { if (item.IsDeleted.HasValue == false || (item.IsDeleted.HasValue == true && item.IsDeleted.Value == false)) { using (UserCompanyRepository sr = new UserCompanyRepository(_context)) { BO.UserCompany BOUserCompany = new BO.UserCompany(); BOUserCompany = sr.Convert <BO.UserCompany, UserCompany>(item); BOUserCompany.User = null; lstUserCompany.Add(BOUserCompany); } } } doctorBO.user.UserCompanies = lstUserCompany; } if (doctor.DoctorLocationSchedules != null) { List <BO.DoctorLocationSchedule> lstDoctorLocationSchedule = new List <BO.DoctorLocationSchedule>(); foreach (var item in doctor.DoctorLocationSchedules) { if (item.IsDeleted.HasValue == false || (item.IsDeleted.HasValue == true && item.IsDeleted.Value == false)) { using (DoctorLocationScheduleRepository sr = new DoctorLocationScheduleRepository(_context)) { BO.DoctorLocationSchedule BODoctorLocationSchedule = new BO.DoctorLocationSchedule(); BODoctorLocationSchedule = sr.Convert <BO.DoctorLocationSchedule, DoctorLocationSchedule>(item); BODoctorLocationSchedule.doctor = null; BODoctorLocationSchedule.schedule = null; lstDoctorLocationSchedule.Add(BODoctorLocationSchedule); } } } doctorBO.DoctorLocationSchedules = lstDoctorLocationSchedule; } } } return((T)(object)doctorBO); }