// GET: Downloads/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var download = await _downloadRepository.Get((int)id); if (download == null) { return(NotFound()); } return(View(download)); }
public async Task <IActionResult> Details(int id, int?page) { var selected = await _downloadRepository.Get(id); if (selected.Deleted || !selected.Enabled) { return(NotFound()); } var language = HttpContext?.Features?.Get <IRequestCultureFeature>()?.RequestCulture?.Culture ?.TwoLetterISOLanguageName ?? "nl"; if (selected.Language != language) { int itemTranslationId; itemTranslationId = language == "nl" ? (await _itemTranslationRepository.GetAllDownloads()).FirstOrDefault(d => d.IdEn == selected.Id).IdNl : (await _itemTranslationRepository.GetAllDownloads()).FirstOrDefault(d => d.IdNl == selected.Id).IdEn; return(RedirectToAction("Details", new { Id = itemTranslationId })); } var AllDownloads = _downloadRepository.GetAll().Where(d => d.Id != id && d.Enabled && !d.Deleted); var viewModel = new DownloadsViewModel { Selected = selected, AllDownloads = await PaginatedList <Download> .Create(AllDownloads.AsQueryable(), page ?? 1, 10) }; return(View("/Views/Downloads/Index.cshtml", viewModel)); }