Ejemplo n.º 1
0
        public async Task <ResponseEntity> GetInfoByIdAsync(dynamic id)
        {
            HashSet <dynamic> listId = new HashSet <dynamic>();

            try
            {
                LopHoc lopHoc = await _lopHocRepository.GetSingleByIdAsync(id);

                if (lopHoc == null)
                {
                    return(new ResponseEntity(StatusCodeConstants.NOT_FOUND));
                }

                ThongTinLopHocViewModel thongTinLopHocVm = _mapper.Map <ThongTinLopHocViewModel>(lopHoc);
                foreach (dynamic item in thongTinLopHocVm.DanhSachGiangVien)
                {
                    listId.Add(item);
                }
                foreach (dynamic item in thongTinLopHocVm.DanhSachMentor)
                {
                    listId.Add(item);
                }
                foreach (dynamic item in thongTinLopHocVm.DanhSachHocVien)
                {
                    listId.Add(item);
                }

                // LẤY DANH SÁCH HỌC VIÊN
                var dsNguoiDung = await _nguoiDungRepository.GetMultiByIdAsync(listId.ToList());

                thongTinLopHocVm.DanhSachNguoiDung = _mapper.Map <List <NguoiDungViewModel> >(dsNguoiDung);

                // LẤY DANH SÁCH KHÓA HỌC ĐÃ KÍCH HOẠT
                List <KhoaHoc> dsKhoaHocKichHoat = await GetCourseActived(lopHoc.MaLoTrinh, lopHoc.NgayBatDau);

                thongTinLopHocVm.DanhSachKhoaHoc = _mapper.Map <List <KhoaHocViewModel> >(dsKhoaHocKichHoat);

                return(new ResponseEntity(StatusCodeConstants.OK, thongTinLopHocVm));
            }
            catch (Exception ex)
            {
                return(new ResponseEntity(StatusCodeConstants.ERROR_SERVER, ex.Message));
            }
        }