public PatientModel GETeditMethod(int?id) { PatientModel rm = new PatientModel(); using (var parepo = new PatientRepository()) { if (id.HasValue && id != 0) { Patient _patient = parepo.GetById(id.Value); rm.userId = _patient.PatientId; rm.Email = _patient.Email; rm.FullName = _patient.FullName; rm.Age = _patient.Age; rm.Surname = _patient.Surname; rm.Title = _patient.Title; rm.MaritalStatus = _patient.MaritalStatus; rm.DOB = _patient.DOB; rm.Sex = _patient.Sex; rm.Address1 = _patient.Address1; rm.Address2 = _patient.Address2; rm.Address3 = _patient.Address3; rm.PostalCode = _patient.PostalCode; rm.Telephone = _patient.Telephone; rm.Employer = _patient.Employer; rm.EmployerTelephone = _patient.EmployerTelephone; rm.Occupation = _patient.Occupation; rm.NationalId = _patient.NationalId; rm.Status = _patient.Status; rm.PatientAllergy = _patient.PatientAllergy; rm.MedicalAidName = _patient.MedicalAidName; rm.MedicalAidNo = _patient.MedicalAidNo; rm.resultFile = _patient.File; rm.FileName = _patient.FileName; rm.FileType = _patient.FileType; foreach (var item in _patient.PatientAddresses.ToList()) { PatientAddressModel padd = new PatientAddressModel(); padd.Address = item.Address; rm.PatientAddresses.Add(padd); } } return(rm); } }
public List <PatientModel> GetAllPatients() { List <PatientModel> pmlist = new List <PatientModel>(); using (var parepo = new PatientRepository()) { var patients = parepo.GetAll().ToList(); foreach (var patient in patients) { PatientModel pm = new PatientModel(); pm.userId = patient.PatientId; pm.Email = patient.Email; pm.FullName = patient.FullName; pm.Surname = patient.Surname; pm.MaritalStatus = patient.MaritalStatus; pm.DOB = patient.DOB; pm.Sex = patient.Sex; pm.Title = patient.Title; pm.Age = patient.Age; //DDLName = PatientDDL(), pm.Address1 = patient.Address1; pm.Address2 = patient.Address2; pm.Address3 = patient.Address3; pm.PostalCode = patient.PostalCode; pm.Telephone = patient.Telephone; pm.Employer = patient.Employer; pm.EmployerTelephone = patient.EmployerTelephone; pm.Occupation = patient.Occupation; pm.NationalId = patient.NationalId; pm.Status = patient.Status; pm.PatientAllergy = patient.PatientAllergy; pm.MedicalAidName = patient.MedicalAidName; pm.MedicalAidNo = patient.MedicalAidNo; pm.resultFile = patient.File; pm.FileName = patient.FileName; pm.FileType = patient.FileType; pm.registeredDate = patient.registeredDate; foreach (var item in patient.PatientAddresses.ToList()) { PatientAddressModel padd = new PatientAddressModel(); padd.Address = item.Address; pm.PatientAddresses.Add(padd); } pmlist.Add(pm); } return(pmlist); #region //return parepo.GetAll().Select(x => new PatientModel() //{ // userId = x.PatientId, // Email = x.Email, // FullName = x.FullName, // Surname = x.Surname, // MaritalStatus = x.MaritalStatus, // DOB = x.DOB, // Sex = x.Sex, // Title = x.Title, // Age = x.Age, // //DDLName = PatientDDL(), // Address1 = x.Address1, // Address2 = x.Address2, // Address3 = x.Address3, // PostalCode = x.PostalCode, // Telephone = x.Telephone, // Employer = x.Employer, // EmployerTelephone = x.EmployerTelephone, // Occupation = x.Occupation, // NationalId = x.NationalId, // Status = x.Status, // PatientAllergy = x.PatientAllergy, // MedicalAidName = x.MedicalAidName, // MedicalAidNo = x.MedicalAidNo, // resultFile = x.File, // FileName = x.FileName, // FileType = x.FileType, // registeredDate = x.registeredDate //}).ToList(); #endregion } }