public tb_person_exercise FindPersonExercise(string personID, int exerciseID) { using (this.database = new ModelEntities()) { return this.database.tb_person_exercise.SingleOrDefault(e => e.ExerciseID == exerciseID && e.PersonID == personID); } }
public tb_exercise FindExerciseByID(int ID) { using (this.database = new ModelEntities()) { return this.database.tb_exercise.SingleOrDefault(e=>e.ExerciseID == ID); } }
public List<tb_exercise> FindExerciseByPerson(string personID) { using (this.database = new ModelEntities()) { return this.database.tb_person_exercise.Where(e=>e.PersonID == personID).Select(e=>e.tb_exercise).ToList(); } }
public List<tb_exercise> FindAllExercise() { using (this.database = new ModelEntities()) { return this.database.tb_exercise.ToList(); } }
public tb_config_practice FindConfigPracticeByID(int? configID) { using (this.database = new ModelEntities()) { return this.database.tb_config_practice.SingleOrDefault(e => e.ConfigID == configID); } }
public List<tb_person> FindAllPatients() { using (database = new ModelEntities()) { return database.tb_person.ToList(); } }
public bool CreatePerson(tb_person _person) { using (database = new ModelEntities()) { database.tb_person.Add(_person); database.SaveChanges(); return true; } }
public List<tb_person> FindPatientByAddress(String address, bool exact) { using (database = new ModelEntities()) { if (!exact) return database.tb_person.Where(p => p.Address.Contains(address)).ToList(); else return database.tb_person.Where(p => p.Address.Equals(address)).ToList(); } }
public tb_person FindPatientByCode(String code) { using (database = new ModelEntities()) { return database.tb_person.SingleOrDefault(p => p.PersonID == code); } }
public bool UpdatePerson(tb_person _person) { using (database = new ModelEntities()) { tb_person patient = database.tb_person.SingleOrDefault(p => p.PersonID == _person.PersonID); patient.FullName = _person.FullName; patient.Birthday = _person.Birthday; patient.Address = _person.Address; patient.Gender = _person.Gender; patient.MobilePhone = _person.MobilePhone; patient.Email = _person.Email; patient.Marital = _person.Marital; patient.Note = _person.Note; database.SaveChanges(); return true; } }
public List<tb_person> FindPatientsByManyConds(String name, String address, String gender, String age, String time) { using (database = new ModelEntities()) { var query = database.tb_person.AsQueryable(); if (name != null && !name.Equals("")) query = query.Where(p => p.FullName.Contains(name)); if (address != null && !address.Equals("")) query = query.Where(p => p.Address.Contains(address)); if (gender != null && !gender.Equals("")) query = query.Where(p => p.Gender.Equals(gender)); switch (age.ToString()) { case "<5": query = query.Where(p => p.Birthday >= DbFunctions.AddYears(DateTime.Now, -5)); break; case "5-10": query = query.Where(p => p.Birthday >= DbFunctions.AddYears(DateTime.Now, -10) && p.Birthday <= DbFunctions.AddYears(DateTime.Now, -5)); break; case "10-15": query = query.Where(p => p.Birthday >= DbFunctions.AddYears(DateTime.Now, -15) && p.Birthday <= DbFunctions.AddYears(DateTime.Now, -10)); break; case "15-30": query = query.Where(p => p.Birthday >= DbFunctions.AddYears(DateTime.Now, -30) && p.Birthday <= DbFunctions.AddYears(DateTime.Now, -15)); break; case "30-60": query = query.Where(p => p.Birthday >= DbFunctions.AddYears(DateTime.Now, -60) && p.Birthday <= DbFunctions.AddYears(DateTime.Now, -30)); break; case ">60": query = query.Where(p => p.Birthday <= DbFunctions.AddYears(DateTime.Now, -60)); break; } return query.ToList(); } }
public List<tb_person> FindPatientByName(String name, bool exact) { using (database = new ModelEntities()) { if (!exact) return database.tb_person.Where(p => p.FullName.Contains(name)).ToList(); else return database.tb_person.Where(p => p.FullName.Equals(name)).ToList(); } }
public List<tb_person> FindPatientByMobile(String mobile, bool exact) { using (database = new ModelEntities()) { if (!exact) return database.tb_person.Where(p => p.MobilePhone.Contains(mobile)).ToList(); else return database.tb_person.Where(p => p.MobilePhone.Equals(mobile)).ToList(); } }
public List<tb_person> FindPatientByCode(String code, bool exact) { List<tb_person> list = null; using (database = new ModelEntities()) { if (!exact) list = database.tb_person.Where(p => p.PersonID.Contains(code)).ToList(); else { list = new List<tb_person>(); list.Add(database.tb_person.SingleOrDefault(p => p.PersonID == code)); } return list; } }