public ActionResult ViewRedirects(int Type, int ShowResultsFrom = 0, string Query = "Null", string Alert = "") { var model = new RedirectsViewModel(); if (Query != "Null") { model.Search = true; model.Query = Query; } else { model.Total = GetTotalRedirects(Type); } if (ShowResultsFrom < 0) { ShowResultsFrom = 0; } else if (ShowResultsFrom > model.Total) { ShowResultsFrom = model.Total - 500; } model.Alert = Alert; model.ShowResultsFrom = ShowResultsFrom; model.Type = Type; switch (Type) { case 1: model.RedirectTypeString = "Short Urls"; model.TypeInfoText = "These short URLs should be used for publicity. Each one is preceded by \"eastsussex.gov.uk / \". For example \"arts\" becomes \"eastsussex.gov.uk/arts\"."; break; case 2: model.RedirectTypeString = "Moved Urls"; model.TypeInfoText = " These pages and sections on eastsussex.gov.uk have moved, but visitors are redirected to the new location."; break; } try { model.RedirectsTable.Table = GetRedirectsTable(Type, ShowResultsFrom, Query); } catch (Exception error) { model.ErrorMessage = error.Message; throw; } return(View(model)); }
public async Task <IActionResult> Index() { var currentUser = await _userManager.GetUserAsync(User); if (currentUser == null) { return(Challenge()); } var redirects = await _redirectService.GetRedirectsForUserAsync(currentUser); var model = new RedirectsViewModel() { Redirects = redirects }; return(View(model)); }
public async Task <IActionResult> Index() { _logger.LogDebug("Home index loaded"); RedirectsViewModel model = null; var currentUser = await _userManager.GetUserAsync(User); if (currentUser != null) { _logger.LogDebug("Authenticated user, querying for existing redirects"); var redirects = await _redirectService.GetRedirectsForUserAsync(currentUser.UserID); model = new RedirectsViewModel() { Redirects = redirects }; } return(View(model)); }