public async Task <IActionResult> Detail(int id, int page = 1) { if (id != 0) { ViewBag.LikedIt = false; var product = await _productrepo.GetById(id); int auth = Barayand.Common.Services.TokenService.AuthorizeUser(Request); if (auth > 0) { ViewBag.LikedIt = await _favoritrepostory.ChekExistsInList(product.P_Id, auth, 1); } ViewBag.loggedin = auth > 0; ViewBag.brand = await _brandrepo.GetById(product.P_BrandId); #region Paging Paging paging = new Paging(); paging.TotalCount = product.Comments.Count(); paging.PageSize = 30; paging.CurrentPage = page; paging.TotalPages = (int)Math.Ceiling(paging.TotalCount / (double)paging.PageSize); ViewBag.paging = paging; #endregion var items = product.Comments.Skip((paging.CurrentPage - 1) * paging.PageSize).Take(paging.PageSize).ToList(); product.Comments = items; return(View(product)); } return(RedirectToAction("Index", "Home")); }