public async Task <ResponseEntity> LayThongTinLichChieuHeThongRap(string maHeThongRap = "", string maNhom = "GP01") { var conn = new SqlConnection(Config.connect); if (conn.State == ConnectionState.Closed) { conn.Open(); } IEnumerable <HeThongRap> lstHeThongRap = db.HeThongRap; if (!string.IsNullOrEmpty(maHeThongRap)) { lstHeThongRap = lstHeThongRap.Where(n => n.MaHeThongRap == maHeThongRap); } List <HeThongRap_> lstResult = new List <HeThongRap_>(); string LichChieu = "LichChieu" + maNhom; string query = string.Format("select HeThongRap.Logo,CumRap.ThongTin,Phim.TenPhim,Phim.HinhAnh,Phim.Hot,Phim.DangChieu,Phim.SapChieu,CumRap.TenCumRap,Rap.TenRap , {0}.MaLichChieu,{0}.MaRap,{0}.MaPhim,{0}.NgayChieuGioChieu,{0}.GiaVe,{0}.ThoiLuong,{0}.MaNhom,{0}.MaHeThongRap,{0}.MaCumRap,TenHeThongRap,TenCumRap from Phim,HeThongRap,CumRap,{0},Rap where Phim.MaPhim = {0}.MaPhim and HeThongRap.MaHeThongRap = {0}.MaHeThongRap and {0}.MaCumRap = CumRap.MaCumRap and {0}.MaRap=Rap.MaRap", LichChieu); if (!string.IsNullOrEmpty(maHeThongRap)) { query = string.Format("select HeThongRap.Logo,CumRap.ThongTin,Phim.TenPhim,Phim.Hot,Phim.DangChieu,Phim.SapChieu,Phim.HinhAnh,CumRap.TenCumRap,Rap.TenRap , {0}.MaLichChieu,{0}.MaRap,{0}.MaPhim,{0}.NgayChieuGioChieu,{0}.GiaVe,{0}.ThoiLuong,{0}.MaNhom,{0}.MaHeThongRap,{0}.MaCumRap,TenHeThongRap,TenCumRap from Phim,HeThongRap,CumRap,{0},Rap where {0}.MaHeThongRap='{1}' and Phim.MaPhim = {0}.MaPhim and HeThongRap.MaHeThongRap = {0}.MaHeThongRap and {0}.MaCumRap = CumRap.MaCumRap and {0}.MaRap=Rap.MaRap", LichChieu, maHeThongRap); } var lstLichChieu = conn.Query <LichChieuMapView>(query); foreach (var ghtr in lstLichChieu.GroupBy(n => new { n.MaHeThongRap, n.TenHeThongRap, n.Logo })) { HeThongRap_ htr = new HeThongRap_(); htr.MaHeThongRap = ghtr.Key.MaHeThongRap; htr.TenHeThongRap = ghtr.Key.TenHeThongRap; htr.Logo = DomainImage + ghtr.Key.Logo; htr.Mahom = ghtr.First().MaNhom; foreach (var cumRap in ghtr.GroupBy(n => new { n.MaCumRap, n.TenCumRap, n.ThongTin })) { CumRap_ cum = new CumRap_(); cum.MaCumRap = cumRap.Key.MaCumRap; cum.TenCumRap = cumRap.Key.TenCumRap; cum.DiaChi = cumRap.Key.ThongTin; cum.HinhAnh = "https://s3img.vcdn.vn/123phim/2021/01/bhd-star-bitexco-16105952137769.png"; foreach (var phim in cumRap.GroupBy(n => new { n.MaPhim, n.TenPhim, n.HinhAnh, n.DangChieu, n.SapChieu, n.Hot })) { Phim_ phimModel = new Phim_(); phimModel.MaPhim = phim.Key.MaPhim; phimModel.TenPhim = phim.Key.TenPhim; phimModel.DangChieu = phim.Key.DangChieu; phimModel.SapChieu = phim.Key.SapChieu; phimModel.Hot = phim.Key.Hot; phimModel.HinhAnh = DomainImage + phim.Key.HinhAnh; foreach (var lichChieu in phim) { LichChieuTheoPhim_ lich = new LichChieuTheoPhim_(); lich.MaRap = lichChieu.MaRap; lich.TenRap = lichChieu.TenRap; lich.NgayChieuGioChieu = lichChieu.NgayChieuGioChieu; lich.GiaVe = lichChieu.GiaVe; lich.MaLichChieu = lichChieu.MaLichChieu; phimModel.lstLichChieuTheoPhim.Add(lich); } cum.DanhSachPhim.Add(phimModel); } htr.lstCumRap.Add(cum); } lstResult.Add(htr); } conn.Close(); return(new ResponseEntity(StatusCodeConstants.OK, lstResult, MessageConstant.MESSAGE_SUCCESS_200)); //return Ok(lstResult); }
public async Task <ActionResult> LayThongTinLichChieuHeThongRap(string maHeThongRap = "", string maNhom = "GP01") { var conn = new SqlConnection(connect); if (conn.State == ConnectionState.Closed) { conn.Open(); } IEnumerable <HeThongRap> lstHeThongRap = db.HeThongRap; if (!string.IsNullOrEmpty(maHeThongRap)) { lstHeThongRap = lstHeThongRap.Where(n => n.MaHeThongRap == maHeThongRap); } List <HeThongRap_> lstResult = new List <HeThongRap_>(); string LichChieu = "LichChieu" + maNhom; string query = string.Format("select HeThongRap.Logo,CumRap.ThongTin,Phim.TenPhim,Phim.HinhAnh,CumRap.TenCumRap,Rap.TenRap , {0}.MaLichChieu,{0}.MaRap,{0}.MaPhim,{0}.NgayChieuGioChieu,{0}.GiaVe,{0}.ThoiLuong,{0}.MaNhom,{0}.MaHeThongRap,{0}.MaCumRap,TenHeThongRap,TenCumRap from Phim,HeThongRap,CumRap,{0},Rap where Phim.MaPhim = {0}.MaPhim and HeThongRap.MaHeThongRap = {0}.MaHeThongRap and {0}.MaCumRap = CumRap.MaCumRap and {0}.MaRap=Rap.MaRap", LichChieu); if (!string.IsNullOrEmpty(maHeThongRap)) { query = string.Format("select HeThongRap.Logo,CumRap.ThongTin,Phim.TenPhim,Phim.HinhAnh,CumRap.TenCumRap,Rap.TenRap , {0}.MaLichChieu,{0}.MaRap,{0}.MaPhim,{0}.NgayChieuGioChieu,{0}.GiaVe,{0}.ThoiLuong,{0}.MaNhom,{0}.MaHeThongRap,{0}.MaCumRap,TenHeThongRap,TenCumRap from Phim,HeThongRap,CumRap,{0},Rap where {0}.MaHeThongRap='{1}' and Phim.MaPhim = {0}.MaPhim and HeThongRap.MaHeThongRap = {0}.MaHeThongRap and {0}.MaCumRap = CumRap.MaCumRap and {0}.MaRap=Rap.MaRap", LichChieu, maHeThongRap); } var lstLichChieu = conn.Query <LichChieuMapView>(query); foreach (var ghtr in lstLichChieu.GroupBy(n => new { n.MaHeThongRap, n.TenHeThongRap, n.Logo })) { HeThongRap_ htr = new HeThongRap_(); htr.MaHeThongRap = ghtr.Key.MaHeThongRap; htr.TenHeThongRap = ghtr.Key.TenHeThongRap; htr.Logo = DomainImage + ghtr.Key.Logo; htr.Mahom = ghtr.First().MaNhom; foreach (var cumRap in ghtr.GroupBy(n => new { n.MaCumRap, n.TenCumRap, n.ThongTin })) { CumRap_ cum = new CumRap_(); cum.MaCumRap = cumRap.Key.MaCumRap; cum.TenCumRap = cumRap.Key.TenCumRap; cum.DiaChi = cumRap.Key.ThongTin; foreach (var phim in cumRap.GroupBy(n => new { n.MaPhim, n.TenPhim, n.HinhAnh })) { Phim_ phimModel = new Phim_(); phimModel.MaPhim = phim.Key.MaPhim; phimModel.TenPhim = phim.Key.TenPhim; phimModel.HinhAnh = DomainImage + phim.Key.HinhAnh; foreach (var lichChieu in phim) { LichChieuTheoPhim_ lich = new LichChieuTheoPhim_(); lich.MaRap = lichChieu.MaRap; lich.TenRap = lichChieu.TenRap; lich.NgayChieuGioChieu = lichChieu.NgayChieuGioChieu; lich.GiaVe = lichChieu.GiaVe; lich.MaLichChieu = lichChieu.MaLichChieu; phimModel.lstLichChieuTheoPhim.Add(lich); } cum.DanhSachPhim.Add(phimModel); } htr.lstCumRap.Add(cum); } lstResult.Add(htr); } conn.Close(); return(Ok(lstResult)); }