public ActionResult Details(string pageParam) { MenuData menu = new MenuData(); if (pageParam == null) { return(RedirectToActionPermanent("List")); } Portfolio portfolio = db.Portfolios.FirstOrDefault(current => current.UrlParameter == pageParam); if (portfolio == null) { return(HttpNotFound()); } string urlAddress = null; if (!string.IsNullOrEmpty(portfolio.AddressUrl)) { urlAddress = "http://" + portfolio.AddressUrl; } PortfolioDetailViewModel pageDetail = new PortfolioDetailViewModel() { Title = portfolio.Title, Body = portfolio.Body, Date = portfolio.LastModificationDate.Value.ToShortDateString(), ImageUrl = portfolio.ImageUrl, CommentCount = db.Comments.Count(current => current.PageId == portfolio.Id && current.IsActive == true && current.IsDelete == false), SidebarPages = GetSidebarPages(portfolio.Id, portfolio.PortfolioGroupId), UrlParameter = portfolio.UrlParameter, PortfolioGroupUrlParameter = portfolio.PortfolioGroup.UrlParameter, PortfolioGroupTitle = portfolio.PortfolioGroup.Title, UrlAddress = urlAddress, Rate = ReturnRate(portfolio), DateModified = portfolio.LastModificationDate.ToString() }; ViewBag.id = portfolio.Id; ViewBag.Title = portfolio.Title + " - زاوش"; ViewBag.Description = portfolio.MetaDescription; ViewBag.Canonical = "https://zavoshsoftware.com/portfoliodetail/" + pageParam; ViewBag.rate = ReturnRate(portfolio); ViewBag.RatingCount = ReturnRatingCount(portfolio.Id); ViewBag.image = "https://zavoshsoftware.com" + portfolio.ImageUrl; ViewBag.creationDate = portfolio.CreationDate; return(View(pageDetail)); }
public async Task <IActionResult> Detail(int id) { Portfolio portfolio = await _projectDb.Portfolio.Include(x => x.Status).Include(x => x.PortfolioTags).ThenInclude(x => x.Tag).FirstOrDefaultAsync(x => x.Id == id); PortfolioDetailViewModel vm = new PortfolioDetailViewModel() { Title = portfolio.Title, CompletionDate = portfolio.CompletionDate, Status = portfolio.Status.Description, Tags = portfolio.PortfolioTags.Select(x => x.Tag.Description).ToList(), PhotoUrl = portfolio.PhotoUrl, Description = portfolio.Description }; return(View(vm)); }