public async Task OnGetAsync(int?Id = 0)
        {
            int pageIndex = 0;
            int pageSize  = 5;


            ////////////////////////////////////////////////////////////////////////////////////

            string searchField = string.Empty;
            string searchQuery = string.Empty;
            bool   searchMode  = false;

            if (!String.IsNullOrEmpty(Request.Query["SearchField"]) &&
                !String.IsNullOrEmpty(Request.Query["SearchQuery"]))
            {
                searchMode  = true;
                searchField = Request.Query["SearchField"];
                searchQuery = Request.Query["SearchQuery"];
            }

            searchingVar             = new SearchingVar();
            searchingVar.SearchMode  = searchMode;
            searchingVar.SearchField = searchField;
            searchingVar.SearchQuery = searchQuery;
            searchingVar.DicField    = new Dictionary <string, string>()
            {
                { "Title", "제목" },
                { "Content", "내용" },
                { "Name", "작성자" }
            };

            //////////////////////////////////////////////////////////////////////////////
            //var iBoard = (IQueryable<mBoard>)_context.mBoards.Where(m => ((m.Category == Category.공지 && m.Step < 1) || (m.Ref == Id)))
            //var iBoard = (IQueryable<mBoard>)_context.mBoards.Where(m => ((m.Step < 1) || (m.Ref == Id)));

            var iBoard = (IQueryable <mBoard>)_context.mBoards;


            //한 번 더 생각
            if (searchMode == false)
            {
                iBoard = iBoard.Where(m => ((m.Step < 1) || (m.Ref == Id)));
            }

            if (searchMode)
            {
                switch (searchField)
                {
                case "Title":
                    iBoard = iBoard.Where(s => s.Title.Contains(searchQuery));
                    break;

                case "Content":
                    iBoard = iBoard.Where(s => s.Content.Contains(searchQuery));
                    break;

                default:
                    iBoard = iBoard.Where(s => s.Content.Contains(searchQuery));
                    break;
                }
            }
            ;

            iBoard = iBoard.OrderByDescending(m => m.Ref).ThenBy(m => m.RefOrder);



            //[1] 쿼리스트링에 따른 페이지 보여주기
            if (!string.IsNullOrEmpty(Request.Query["Page"]))
            {
                // Page는 보여지는 쪽은 1, 2, 3, ... 코드단에서는 0, 1, 2, ...
                pageIndex = Convert.ToInt32(Request.Query["Page"]) - 1;
                //Response.Cookies.Append("Page", pageIndex.ToString());
            }

            TotalCount = iBoard.Count();
            PageIndex  = pageIndex + 1;

            mBoard = await iBoard
                     .Skip((pageIndex) *pageSize).Take(pageSize).ToListAsync();
        }
Beispiel #2
0
        public async Task OnGetAsync()
        {
            int pageIndex = 0;
            int pageSize  = 3;


            ////////////////////////////////////////////////////////////////////////////////////

            string searchField = string.Empty;
            string searchQuery = string.Empty;
            bool   searchMode  = false;

            if (!String.IsNullOrEmpty(Request.Query["SearchField"]) &&
                !String.IsNullOrEmpty(Request.Query["SearchQuery"]))
            {
                searchMode  = true;
                searchField = Request.Query["SearchField"];
                searchQuery = Request.Query["SearchQuery"];
            }

            searchingVar             = new SearchingVar();
            searchingVar.SearchMode  = searchMode;
            searchingVar.SearchField = searchField;
            searchingVar.SearchQuery = searchQuery;
            searchingVar.DicField    = new Dictionary <string, string>()
            {
                { "LastName", "성" },
                { "FirstMidName", "이름" },
                { "Name", "전체" }
            };

            //////////////////////////////////////////////////////////////////////////////

            var iStudent = (IQueryable <Student>)_context.Students
                           .Include(s => s.Enrollments)
                           .ThenInclude(e => e.Course);

            if (searchMode)
            {
                switch (searchField)
                {
                case "LastName":
                    iStudent = iStudent.Where(s => s.LastName.Contains(searchQuery));
                    break;

                case "FirstMidName":
                    iStudent = iStudent.Where(s => s.FirstMidName.Contains(searchQuery));
                    break;

                default:
                    iStudent = iStudent.Where(s => s.FirstMidName.Contains(searchQuery) || s.LastName.Contains(searchQuery));
                    break;
                }
            }


            iStudent = iStudent.OrderByDescending(s => s.ID);



            //[1] 쿼리스트링에 따른 페이지 보여주기
            if (!string.IsNullOrEmpty(Request.Query["Page"]))
            {
                // Page는 보여지는 쪽은 1, 2, 3, ... 코드단에서는 0, 1, 2, ...
                pageIndex = Convert.ToInt32(Request.Query["Page"]) - 1;
                //Response.Cookies.Append("Page", pageIndex.ToString());
            }

            TotalCount = iStudent.Count();
            PageIndex  = pageIndex + 1;

            Student = await iStudent
                      .Skip((pageIndex) *pageSize).Take(pageSize).ToListAsync();
        }
Beispiel #3
0
 public IViewComponentResult Invoke(SearchingVar searchingVar)
 {
     return(View(searchingVar));
 }
        public async Task OnGetAsync(int?id, int?courseID)
        {
            int pageIndex = 0;
            int pageSize  = 3;

            string searchField = string.Empty;
            string searchQuery = string.Empty;
            bool   searchMode  = false;

            ////////////////////////////////////////////////////////////////////////////////////

            if (!String.IsNullOrEmpty(Request.Query["SearchField"]) &&
                !String.IsNullOrEmpty(Request.Query["SearchQuery"]))
            {
                searchMode  = true;
                searchField = Request.Query["SearchField"];
                searchQuery = Request.Query["SearchQuery"];
            }

            searchingVar             = new SearchingVar();
            searchingVar.SearchMode  = searchMode;
            searchingVar.SearchField = searchField;
            searchingVar.SearchQuery = searchQuery;
            searchingVar.DicField    = new Dictionary <string, string>()
            {
                { "LastName", "성" },
                { "FirstMidName", "이름" },
                { "Name", "전체" }
            };

            //////////////////////////////////////////////////////////////////////////////


            Instructor = new InstructorIndexData();
            var iqInstructor = (IQueryable <Instructor>)_context.Instructors
                               .Include(i => i.OfficeAssignment)
                               .Include(i => i.CourseAssignments)
                               .ThenInclude(c => c.Course)
                               .ThenInclude(c => c.Department);

            //.Include(i => i.CourseAssignments)
            //    .ThenInclude(c => c.Course)
            //        .ThenInclude(c => c.Enrollments)
            //            .ThenInclude(e => e.Student);

            if (searchMode)
            {
                switch (searchField)
                {
                case "LastName":
                    iqInstructor = iqInstructor.Where(s => s.LastName.Contains(searchQuery));
                    break;

                case "FirstMidName":
                    iqInstructor = iqInstructor.Where(s => s.FirstMidName.Contains(searchQuery));
                    break;

                default:
                    iqInstructor = iqInstructor.Where(s => s.FirstMidName.Contains(searchQuery) || s.LastName.Contains(searchQuery));
                    break;
                }
            }

            iqInstructor = iqInstructor.OrderByDescending(i => i.ID);



            //[1] 쿼리스트링에 따른 페이지 보여주기
            if (!string.IsNullOrEmpty(Request.Query["Page"]))
            {
                // Page는 보여지는 쪽은 1, 2, 3, ... 코드단에서는 0, 1, 2, ...
                pageIndex = Convert.ToInt32(Request.Query["Page"]) - 1;
                //Response.Cookies.Append("Page", pageIndex.ToString());
            }

            TotalCount = iqInstructor.Count();
            PageIndex  = pageIndex + 1;

            Instructor.Instructors = await iqInstructor
                                     .Skip((pageIndex) *pageSize).Take(pageSize).ToListAsync();


            if (id != null)
            {
                InstructorID = id.Value;
                var inss = Instructor.Instructors.Where(i => i.ID == id.Value).Single();
                Instructor.Courses = inss.CourseAssignments.Select(c => c.Course);
            }

            if (courseID != null)
            {
                CourseID = courseID.Value;

                //Instructor.Enrollments =_context.Courses
                //    .Include(c=>c.Enrollments)
                //        .ThenInclude(e=>e.Student)
                //     .Where(x => x.CourseID == courseID).Single().Enrollments;

                var selectedCourse = Instructor.Courses.SingleOrDefault(c => c.CourseID == courseID);
                await _context.Entry(selectedCourse).Collection(x => x.Enrollments).LoadAsync();

                foreach (var item in selectedCourse.Enrollments)
                {
                    await _context.Entry(item).Reference(x => x.Student).LoadAsync();
                }
                Instructor.Enrollments = selectedCourse.Enrollments;
            }
        }
Beispiel #5
0
        public async Task OnGetAsync()
        {
            ///// Paging 변수 초기화

            int pageIndex = 0;
            int pageSize  = 3;


            ////////  Searching 변수 초기화  ///////////////////////////////////////////////////////////////////////////

            string searchField = string.Empty;
            string searchQuery = string.Empty;
            bool   searchMode  = false;

            if (!String.IsNullOrEmpty(Request.Query["SearchField"]) &&
                !String.IsNullOrEmpty(Request.Query["SearchQuery"]))
            {
                searchMode  = true;
                searchField = Request.Query["SearchField"];
                searchQuery = Request.Query["SearchQuery"];
            }

            searchingVar             = new SearchingVar();
            searchingVar.SearchMode  = searchMode;
            searchingVar.SearchField = searchField;
            searchingVar.SearchQuery = searchQuery;
            searchingVar.DicField    = new Dictionary <string, string>()
            {
                { "Title", "제목" },
                { "Genee", "장르" }
            };

            //////////////////////////////////////////////////////////////////////////////

            var iMovie = (IQueryable <Movie>)_context.Movies.Include(m => m.AttachFiles).AsNoTracking();


            if (searchMode)
            {
                switch (searchField)
                {
                case "Title":
                    iMovie = iMovie.Where(s => s.Title.Contains(searchQuery));
                    break;

                case "Gener":
                    iMovie = iMovie.Where(s => s.Gener.Contains(searchQuery));
                    break;

                default:
                    iMovie = iMovie.Where(s => s.Title.Contains(searchQuery));
                    break;
                }
            }


            iMovie = iMovie.OrderByDescending(s => s.ID);



            //[1] 쿼리스트링에 따른 페이지 보여주기
            if (!string.IsNullOrEmpty(Request.Query["Page"]))
            {
                // Page는 보여지는 쪽은 1, 2, 3, ... 코드단에서는 0, 1, 2, ...
                pageIndex = Convert.ToInt32(Request.Query["Page"]) - 1;
                //Response.Cookies.Append("Page", pageIndex.ToString());
            }

            TotalCount = iMovie.Count();
            PageIndex  = pageIndex + 1;

            Movie = await iMovie
                    .Skip((pageIndex) *pageSize).Take(pageSize).ToListAsync();
        }
Beispiel #6
0
        public async Task OnGetAsync()
        {
            int pageIndex = 0;
            int pageSize  = 3;

            string searchField = string.Empty;
            string searchQuery = string.Empty;
            bool   searchMode  = false;

            ////////////////////////////////////////////////////////////////////////////////////

            if (!String.IsNullOrEmpty(Request.Query["SearchField"]) &&
                !String.IsNullOrEmpty(Request.Query["SearchQuery"]))
            {
                searchMode  = true;
                searchField = Request.Query["SearchField"];
                searchQuery = Request.Query["SearchQuery"];
            }

            searchingVar             = new SearchingVar();
            searchingVar.SearchMode  = searchMode;
            searchingVar.SearchField = searchField;
            searchingVar.SearchQuery = searchQuery;
            searchingVar.DicField    = new Dictionary <string, string>()
            {
                { "CourseID", "강의번호" },
                { "Title", "강의명" },
                { "Department", "부서" }
            };

            //////////////////////////////////////////////////////////////////////////////


            var iCourse = (IQueryable <Course>)_context.Courses
                          .Include(c => c.Department);

            if (searchMode)
            {
                switch (searchField)
                {
                case "CourseID":
                    iCourse = iCourse.Where(s => s.CourseID == int.Parse(searchQuery));
                    break;

                case "Title":
                    iCourse = iCourse.Where(s => s.Title.Contains(searchQuery));
                    break;

                default:
                    iCourse = iCourse.Where(s => s.Department.Name.Contains(searchQuery));
                    break;
                }
            }

            //[1] 쿼리스트링에 따른 페이지 보여주기
            if (!string.IsNullOrEmpty(Request.Query["Page"]))
            {
                // Page는 보여지는 쪽은 1, 2, 3, ... 코드단에서는 0, 1, 2, ...
                pageIndex = Convert.ToInt32(Request.Query["Page"]) - 1;
                //Response.Cookies.Append("Page", pageIndex.ToString());
            }

            TotalCount = iCourse.Count();
            PageIndex  = pageIndex + 1;

            Course = await iCourse
                     .Skip((pageIndex) *pageSize).Take(pageSize).ToListAsync();
        }