public async Task <IActionResult> Create(string id_CTDT)
        {
            //Lấy danh sách môn học để show thành list
            var requestMonHoc = new MonHocManagePagingRequest()
            {
                PageIndex = 1,
                PageSize  = 1000
            };
            var monHocs = await _monHocApiClient.GetAllPaging(requestMonHoc);

            ViewBag.monHocs = monHocs.Items;

            //Lấy danh sách học kỳ để show thành list
            var requestHocKy = new HocKyNamHocManagePagingRequest()
            {
                PageIndex = 1,
                PageSize  = 1000
            };

            var hocKys = await _hocKyNamHocApiClient.GetAllPaging(requestHocKy);

            ViewBag.hocKys = hocKys.Items;

            return(View());
        }
示例#2
0
        public async Task <PagedResult <HocKyNamHocViewModel> > GetAllPaging(HocKyNamHocManagePagingRequest request)
        {
            var query = from hocKyNamHoc
                        in _context.HocKy_NamHocs
                        orderby hocKyNamHoc.NamHoc, hocKyNamHoc.HocKy
                select new { hocKyNamHoc };

            if (!string.IsNullOrEmpty(request.Keyword))
            {
                query = query.Where(x => x.hocKyNamHoc.NamHoc.ToString().Contains(request.Keyword) || x.hocKyNamHoc.HocKy.ToString().Contains(request.Keyword));
            }

            int totalRow = await query.CountAsync();

            var data = await query.Skip((request.PageIndex - 1) *request.PageSize)
                       .Take(request.PageSize)
                       .Select(x => new HocKyNamHocViewModel()
            {
                HocKy       = x.hocKyNamHoc.HocKy,
                NamHoc      = x.hocKyNamHoc.NamHoc,
                NgayBatDau  = x.hocKyNamHoc.NgayBatDau,
                NgayKetThuc = x.hocKyNamHoc.NgayKetThuc
            }).ToListAsync();

            var pagedResult = new PagedResult <HocKyNamHocViewModel>()
            {
                TotalRecords = totalRow,
                PageIndex    = request.PageIndex,
                PageSize     = request.PageSize,
                Items        = data
            };

            return(pagedResult);
        }
        public async Task <IActionResult> CreateChiTietCTDT(string id)
        {
            var namApDung = await _chuongTrinhDaoTao.GetById(id);

            var nam = namApDung.Nam;

            ViewBag.Nam = nam;

            //Lấy danh sách môn học để show thành list
            var requestMonHoc = new MonHocManagePagingRequest()
            {
                PageIndex = 1,
                PageSize  = 1000
            };
            var monHocs = await _monHocApiClient.GetAllPaging(requestMonHoc);

            ViewBag.monHocs = monHocs.Items;

            //Lấy danh sách học kỳ để show thành list
            var requestHocKy = new HocKyNamHocManagePagingRequest()
            {
                PageIndex = 1,
                PageSize  = 1000
            };

            ViewBag.ID_CTDT = id;

            return(View());
        }
        public async Task <IActionResult> Index(string keyword, int pageIndex = 1, int pageSize = 9)
        {
            var request = new HocKyNamHocManagePagingRequest()
            {
                Keyword   = keyword,
                PageIndex = pageIndex,
                PageSize  = pageSize
            };
            var data = await _hocKyNamHocApiClient.GetAllPaging(request);

            ViewBag.Keyword = keyword;

            if (TempData["result"] != null)
            {
                ViewBag.SuccessMessage = TempData["result"];
            }

            return(View(data));
        }
示例#5
0
        public async Task <PagedResult <HocKyNamHocViewModel> > GetAllPaging(HocKyNamHocManagePagingRequest request)
        {
            var sessions = _httpContextAccessor
                           .HttpContext
                           .Session
                           .GetString(SystemConstants.AppSettings.Token);

            var client = _httpClientFactory.CreateClient();

            client.BaseAddress = new Uri(_configuration[SystemConstants.AppSettings.BaseAddress]);
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", sessions);

            var response = await client.GetAsync(
                $"/api/hockynamhocs/paging?pageIndex={request.PageIndex}" +
                $"&pageSize={request.PageSize}" +
                $"&keyword={request.Keyword}"
                );

            var body = await response.Content.ReadAsStringAsync();

            var sinhVien = JsonConvert.DeserializeObject <PagedResult <HocKyNamHocViewModel> >(body);

            return(sinhVien);
        }
        public async Task <IActionResult> GetAllPaging([FromQuery] HocKyNamHocManagePagingRequest request)
        {
            var hocKyNamHoc = await _hocKyNamHocService.GetAllPaging(request);

            return(Ok(hocKyNamHoc));
        }