public async Task <ResponseEntity> LayThongTinLichChieuPhim(int MaPhim = 0) { Phim p = db.Phim.SingleOrDefault(n => n.MaPhim == MaPhim); if (p == null) { return(new ResponseEntity(StatusCodeConstants.BAD_REQUEST, "Mã phim không tồn tại!", MessageConstant.BAD_REQUEST)); } var conn = new SqlConnection(Config.connect); //List<ChiTietPhimTheoHeThongRap> lstResult = new List<ChiTietPhimTheoHeThongRap>(); LichChieuTheoPhim phim = new LichChieuTheoPhim(); phim.MaPhim = p.MaPhim; phim.TenPhim = p.TenPhim; phim.BiDanh = p.BiDanh; phim.Trailer = p.Trailer; phim.HinhAnh = DomainImage + p.HinhAnh; phim.MoTa = p.MoTa; phim.MaNhom = p.MaNhom; phim.NgayKhoiChieu = p.NgayKhoiChieu; phim.DanhGia = p.DanhGia; phim.Hot = p.Hot; phim.DangChieu = p.DangChieu; phim.SapChieu = p.SapChieu; foreach (var item in db.HeThongRap) { string LichChieu = "LichChieu" + p.MaNhom; string query = string.Format("select HeThongRap.Logo, CumRap.ThongTin,Phim.TenPhim,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}.MaHeThongRap = '{1}' and {0}.MaPhim= {2} and {0}.MaRap=Rap.MaRap", LichChieu, item.MaHeThongRap, p.MaPhim); var lstLichChieu = conn.Query <LichChieuMapView>(query); foreach (var htr in lstLichChieu.GroupBy(n => new { n.MaHeThongRap, n.TenHeThongRap, n.Logo })) { ThongTinLichChieuHeThongRap heThongRap = new ThongTinLichChieuHeThongRap(); heThongRap.Logo = DomainImage + htr.Key.Logo; heThongRap.MaHeThongRap = htr.Key.MaHeThongRap; heThongRap.TenHeThongRap = htr.Key.TenHeThongRap; foreach (var cumRap in htr.GroupBy(n => new { n.MaCumRap, n.TenCumRap, n.ThongTin })) { ThongTinLichChieuCumRap cum = new ThongTinLichChieuCumRap(); cum.MaCumRap = cumRap.Key.MaCumRap; cum.TenCumRap = cumRap.Key.TenCumRap; cum.HinhAnh = "https://s3img.vcdn.vn/123phim/2021/01/bhd-star-bitexco-16105952137769.png"; cum.DiaChi = cumRap.Key.ThongTin; foreach (var lichChieu in cumRap) { LichChieuPhim lcPhim = new LichChieuPhim(); lcPhim.MaLichChieu = lichChieu.MaLichChieu.ToString(); lcPhim.MaRap = lichChieu.MaRap; lcPhim.TenRap = lichChieu.TenRap; lcPhim.GiaVe = lichChieu.GiaVe; lcPhim.ThoiLuong = lichChieu.ThoiLuong; lcPhim.NgayChieuGioChieu = lichChieu.NgayChieuGioChieu; cum.LichChieuPhim.Add(lcPhim); } heThongRap.CumRapChieu.Add(cum); } phim.HeThongRapChieu.Add(heThongRap); } } conn.Close(); //return Ok(phim); return(new ResponseEntity(StatusCodeConstants.OK, phim, MessageConstant.MESSAGE_SUCCESS_200)); }
public async Task <ActionResult> LayThongTinLichChieuPhim(int MaPhim = 0) { Phim p = db.Phim.SingleOrDefault(n => n.MaPhim == MaPhim); if (p == null) { return(await tbl.TBLoi(ThongBaoLoi.Loi400, "Mã phim không tồn tại!")); } var conn = new SqlConnection(connect); //List<ChiTietPhimTheoHeThongRap> lstResult = new List<ChiTietPhimTheoHeThongRap>(); LichChieuTheoPhim phim = new LichChieuTheoPhim(); phim.MaPhim = p.MaPhim; phim.TenPhim = p.TenPhim; phim.BiDanh = p.BiDanh; phim.Trailer = p.Trailer; phim.HinhAnh = DomainImage + p.HinhAnh; phim.MoTa = p.MoTa; phim.MaNhom = p.MaNhom; phim.NgayKhoiChieu = p.NgayKhoiChieu; phim.DanhGia = p.DanhGia; foreach (var item in db.HeThongRap) { string LichChieu = "LichChieu" + p.MaNhom; string query = string.Format("select HeThongRap.Logo, CumRap.ThongTin,Phim.TenPhim,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}.MaHeThongRap = '{1}' and {0}.MaPhim= {2} and {0}.MaRap=Rap.MaRap", LichChieu, item.MaHeThongRap, p.MaPhim); var lstLichChieu = conn.Query <LichChieuMapView>(query); foreach (var htr in lstLichChieu.GroupBy(n => new { n.MaHeThongRap, n.TenHeThongRap, n.Logo })) { ThongTinLichChieuHeThongRap heThongRap = new ThongTinLichChieuHeThongRap(); heThongRap.Logo = DomainImage + htr.Key.Logo; heThongRap.MaHeThongRap = htr.Key.MaHeThongRap; heThongRap.TenHeThongRap = htr.Key.TenHeThongRap; foreach (var cumRap in htr.GroupBy(n => new { n.MaCumRap, n.TenCumRap })) { ThongTinLichChieuCumRap cum = new ThongTinLichChieuCumRap(); cum.MaCumRap = cumRap.Key.MaCumRap; cum.TenCumRap = cumRap.Key.TenCumRap; foreach (var lichChieu in cumRap) { LichChieuPhim lcPhim = new LichChieuPhim(); lcPhim.MaLichChieu = lichChieu.MaLichChieu.ToString(); lcPhim.MaRap = lichChieu.MaRap; lcPhim.TenRap = lichChieu.TenRap; lcPhim.GiaVe = lichChieu.GiaVe; lcPhim.ThoiLuong = lichChieu.ThoiLuong; lcPhim.NgayChieuGioChieu = lichChieu.NgayChieuGioChieu; cum.LichChieuPhim.Add(lcPhim); } heThongRap.CumRapChieu.Add(cum); } phim.HeThongRapChieu.Add(heThongRap); } } conn.Close(); return(Ok(phim)); }