public List <T> GetAll() { using (var context = DKClinicEntities.Create()) { return(context.Set <T>().ToList()); } }
// 전달받은 리스트의 값에 DepartmentName과 TypeName값을 추가해주는 메서드 public List <Question> AddDepartmentNameAndTypeName(List <Question> questions) { using (var context = DKClinicEntities.Create()) { List <Department> departments = Dao.Department.GetAll(); foreach (Question question in questions) { question.DepartmentName = departments .Where(x => x.DepartmentID == question.DepartmentID) .Select(x => x.Name).FirstOrDefault(); if (question.Type == 1) { question.TypeName = "주관식"; } else if (question.Type == 2) { question.TypeName = "객관식"; } else if (question.Type == 3) { question.TypeName = "객관식(다중선택)"; } } } return(questions); }
public int GetCount() { using (var context = DKClinicEntities.Create()) { return(context.Set <T>().Count()); } }
public Employee GetByName(string name) { using (var context = DKClinicEntities.Create()) { return context.Employees.Where(x => x.Name == name) .FirstOrDefault(); } }
public Customer Find(string name, string birthdate) { using (var context = DKClinicEntities.Create()) { return(context.Customers.Where(x => x.Name == name && x.Birthdate == birthdate) .FirstOrDefault()); } }
public void Delete(T entity) { using (var context = DKClinicEntities.Create()) { context.Entry(entity).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }
public void Insert(T entity) { using (var context = DKClinicEntities.Create()) { context.Set <T>().Add(entity); context.SaveChanges(); } }
// 진료과에 해당하는 Questino 테이블의 값을 전달받는 메서드 public List <Question> GetByDepartmentID(int departmentID) { using (var context = DKClinicEntities.Create()) { var query = context.Questions .Where(x => x.DepartmentID == departmentID) .Select(x => x); return(query.ToList()); } }
public List<Customer> GetGenderWithGenderID() { using(var context = DKClinicEntities.Create()) { var query = from x in context.Customers select new { Customer = x, GenderName = x.Gender.Name }; var list = query.ToList(); foreach(var item in list) { item.Customer.Gender.Name= item.GenderName; } return list.ConvertAll(x => x.Customer); } }
public Employee GetWithDepartmentAndPositionNameByName(string name) { using (var context = DKClinicEntities.Create()) { var query = from x in context.Employees.Where(x => x.Name == name) select new { Employee = x, DepartmentName = x.Department.Name, PositionName = x.Position.Name }; var item = query.ToList().FirstOrDefault(); if (item == null) return null; item.Employee.DepartmentName = item.DepartmentName; item.Employee.PositionName = item.PositionName; return item.Employee; } }
public List<Employee> GetWithDepartmentAndPositionName() { using (var context = DKClinicEntities.Create()) { var query = from x in context.Employees select new { Employee = x, DepartmentName = x.Department.Name, PositionName = x.Position.Name }; var list = query.ToList(); foreach (var item in list) { item.Employee.DepartmentName = item.DepartmentName; item.Employee.PositionName = item.PositionName; } return list.ConvertAll(x => x.Employee); } }
public List <Customer> GetByName(string name) { using (var context = DKClinicEntities.Create()) { var query = from x in context.Customers select new { Customer = x, SearchName = x.Name, GenderName = x.Gender.Name }; query = query.Where(x => x.Customer.Name == name); var list = query.ToList(); foreach (var item in list) { item.Customer.GenderName = item.GenderName; } return(list.ConvertAll(x => x.Customer)); } }
public List <Questionnare> GetWithDepartmentAndCustomerName(Employee employee) { using (var context = DKClinicEntities.Create()) { var query = from x in context.Questionnares where x.DepartmentID == employee.DepartmentID select new { Questionnare = x, DepartmentName = x.Department.Name, CustomerName = x.Customer.Name }; var list = query.ToList(); foreach (var item in list) { item.Questionnare.DepartmentName = item.DepartmentName; item.Questionnare.CustomerName = item.CustomerName; } return(list.ConvertAll(x => x.Questionnare)); } }
public List <Employee> GetWithDepartmentAndPositionNameByName(string name) { using (var context = DKClinicEntities.Create()) { var query = from x in context.Employees.Where(x => x.Name == name) select new { Employee = x, DepartmentName = x.Department.Name, PositionName = x.Position.Name }; var list = query.ToList(); if (list == null) { return(null); } foreach (var item in list) { item.Employee.DepartmentName = item.DepartmentName; item.Employee.PositionName = item.PositionName; } return(list.ConvertAll(x => x.Employee)); } }