예제 #1
0
 public List <T> GetAll()
 {
     using (var context = DKClinicEntities.Create())
     {
         return(context.Set <T>().ToList());
     }
 }
예제 #2
0
        // 전달받은 리스트의 값에 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);
        }
예제 #3
0
 public int GetCount()
 {
     using (var context = DKClinicEntities.Create())
     {
         return(context.Set <T>().Count());
     }
 }
예제 #4
0
 public Employee GetByName(string name)
 {
     using (var context = DKClinicEntities.Create())
     {
         return context.Employees.Where(x => x.Name == name)
                                 .FirstOrDefault();
     }
 }
예제 #5
0
 public Customer Find(string name, string birthdate)
 {
     using (var context = DKClinicEntities.Create())
     {
         return(context.Customers.Where(x => x.Name == name && x.Birthdate == birthdate)
                .FirstOrDefault());
     }
 }
예제 #6
0
        public void Delete(T entity)
        {
            using (var context = DKClinicEntities.Create())
            {
                context.Entry(entity).State = System.Data.Entity.EntityState.Deleted;

                context.SaveChanges();
            }
        }
예제 #7
0
        public void Insert(T entity)
        {
            using (var context = DKClinicEntities.Create())
            {
                context.Set <T>().Add(entity);

                context.SaveChanges();
            }
        }
예제 #8
0
        // 진료과에 해당하는 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());
            }
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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;
            }
        }
예제 #11
0
        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);
            }
        }
예제 #12
0
        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));
            }
        }
예제 #13
0
        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));
            }
        }
예제 #14
0
        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));
            }
        }