public ActionResult Details(int?Rid) { if (Convert.ToInt32(Session["Level"]) == 1 || Session["Level"] == null) { return(RedirectToAction("Index", "Home")); } if (Rid == null) { return(RedirectToAction("Index", "NhaHang")); } var a = db.FullInfoRestaurant(Rid).Count(); if (a == 0) { TempData["Failed"] = "Không tồn tại nhà hàng trong CSDL."; return(RedirectToAction("Index", "NhaHang")); } PasgoRestaurant results = db.FullInfoRestaurant(Rid).ElementAt(0); List <allImg_Result> resultsimg = new List <allImg_Result>(); List <thongtinthemSP_Result> resulttt = new List <thongtinthemSP_Result>(); //Nếu nhà hàng không có trong danh sách thuộc thương hiệu thì ds trả về = null -> lỗi, không push object null đc var listchuoi = db.ThuocThuongHieuChuoi(Rid); ThuocThuongHieuChuoi_Result resultchuoi = new ThuocThuongHieuChuoi_Result(); ThuocThuongHieuChuoi_Result thaydoi = new ThuocThuongHieuChuoi_Result { IdThuongHieu = 0, Name = "(Chưa cập nhật)", AddressDT = "(Chưa cập nhật)", LinkTH = "https://via.placeholder.com/400x210.png?text=ch%C6%B0a+c%E1%BA%ADp+nh%E1%BA%ADt", ImgDT = "https://via.placeholder.com/400x210.png?text=ch%C6%B0a+c%E1%BA%ADp+nh%E1%BA%ADt", ImgTH = "(Chưa cập nhật)" }; if (listchuoi.Count() == 0) { resultchuoi = thaydoi; } else { resultchuoi = db.ThuocThuongHieuChuoi(Rid).ElementAt(0); } var rsimg = db.allImg(Rid); var rstt = db.thongtinthemSP(Rid); foreach (var item in rsimg.ToList()) { resultsimg.Add(item); } foreach (var item in rstt.ToList()) { resulttt.Add(item); } return(View(Tuple.Create(results, resultsimg.ToList(), resulttt.ToList(), resultchuoi))); }