public List <HocSinhDtoList> getAllHocSinhDTO() { List <HocSinhDtoList> result = new List <HocSinhDtoList>(); var temp = connect.HocSinhs.ToList(); foreach (var item in temp) { HocSinhDtoList data = new HocSinhDtoList(); data = new ConvertEntityToModel().ConvertHocSinhToDtoList(item); var lop = connect.Lops.Where(x => x.Id == item.IdLop).FirstOrDefault(); data.Lop = lop != null ? lop.TenLop : ""; result.Add(data); } return(result); }
public HocSinhDtoList ConvertHocSinhToDtoList(HocSinh hocsinh) { HocSinhDtoList result = new HocSinhDtoList(); result.MaHocSinh = hocsinh.MaHocSinh; result.TenHocSinh = hocsinh.TenHocSinh; result.NgaySinh = hocsinh.NgaySinh; result.DiaChi = hocsinh.DiaChi; result.NamBatDau = hocsinh.NamBatDau; result.GhiChu = hocsinh.GhiChu; if (hocsinh.GioiTinh == (int)GlobalParam.GioiTinh.NAM) { result.GioiTinh = GlobalParam.GioiTinhString.Nam.ToString(); } else if (hocsinh.GioiTinh == (int)GlobalParam.GioiTinh.NU) { result.GioiTinh = GlobalParam.GioiTinhString.Nữ.ToString(); } return(result); }