Exemplo n.º 1
0
 public List <T> GetAll()
 {
     using (var context = DKClinicEntities.Create())
     {
         return(context.Set <T>().ToList());
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 public int GetCount()
 {
     using (var context = DKClinicEntities.Create())
     {
         return(context.Set <T>().Count());
     }
 }
Exemplo n.º 4
0
 public Employee GetByName(string name)
 {
     using (var context = DKClinicEntities.Create())
     {
         return context.Employees.Where(x => x.Name == name)
                                 .FirstOrDefault();
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 6
0
        public void Delete(T entity)
        {
            using (var context = DKClinicEntities.Create())
            {
                context.Entry(entity).State = System.Data.Entity.EntityState.Deleted;

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

                context.SaveChanges();
            }
        }
Exemplo n.º 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());
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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));
            }
        }