/// <summary> /// Displays a add news source view. /// </summary> /// <param name="id"></param> /// <returns>View</returns> public IActionResult AddNewsSource(int id) { // Find the category from the supplied ID var category = _newsCategoryRepo.ReadUserSettingNewsCategory(id); // Find the identity user var user = _userSettingRepo.Read(User.Identity.Name); // When both are undefined, redirect the user to the index if (category == null || user == null) { return(RedirectToAction("Index", "Profile")); } // Instantiate a new add source view model var sourceVM = new AddSourceVM { ExistingNewSources = category.NewsSources, UserSettingNewsCategory = category, CategoryName = category.NewsCategory.Name, CategoryId = category.Id, Language = user.Language, Country = user.Country }; return(View(sourceVM)); }