public async Task <GiangVienViewModel> GetById(string id) { var giangVien = await _context.GiangViens.FindAsync(id); if (giangVien == null) { throw new QuanLySinhVien_Exceptions($"Không thể tìm thấy: {id}"); } var giangVienViewModel = new GiangVienViewModel() { ID = giangVien.ID, SoThuTu = giangVien.SoThuTu, Ho = giangVien.Ho, Ten = giangVien.Ten, HoTen = giangVien.HoTen, DiaChi = giangVien.DiaChi, Email = giangVien.Email, SoDienThoai = giangVien.SoDienThoai, GioiTinh = giangVien.GioiTinh, NgaySinh = giangVien.NgaySinh, IsActive = giangVien.IsActive, }; return(giangVienViewModel); }
public async Task <IActionResult> Details(string id) { var giangVien = await _giangVienApiClient.GetById(id); if (giangVien != null) { var monHocViewModel = new GiangVienViewModel() { ID = giangVien.ID, Ho = giangVien.Ho, Ten = giangVien.Ten, HoTen = giangVien.HoTen, DiaChi = giangVien.DiaChi, Email = giangVien.Email, SoDienThoai = giangVien.SoDienThoai, GioiTinh = giangVien.GioiTinh, NgaySinh = giangVien.NgaySinh, IsActive = giangVien.IsActive }; return(View(monHocViewModel)); } return(RedirectToAction("Error", "Home")); }