/// <summary>
        /// Index view to all the user to manage their profile
        /// </summary>
        /// <returns>View</returns>
        public IActionResult Index()
        {
            var user = _userSettingRepo.Read(User.Identity.Name);

            // When the user is not found redirect to a login page
            if (user == null)
            {
                return(LocalRedirect("/Identity/Account/Login"));
            }

            // Get all the news categories that the user does not have
            var subtracted = _newsCategoryRepo.ReadAll().Where(n => !n.UserSettingNewsCategories.Select(news => news.NewsCategory.Name).Contains(n.Name)).ToList();

            // Get all the news categories of the user
            var newsCatList = _newsCategoryRepo.Read(user.Id).UserSettingNewsCategories.ToList();

            // Instantiate a new profile manager view model
            var userVM = new ProfileManageVM {
                Username  = user.User.UserName,
                FirstName = user.FirstName,
                LastName  = user.LastName,
                Language  = user.Language,
                Country   = user.Country,
                SubtractedNewsCategoriesOptions = subtracted,
                UserSettingNewsCategories       = newsCatList
            };

            return(View(userVM));
        }
        /// <summary>
        /// Index view to display the news.
        /// Provides a profile manage view model
        /// with important information about a user
        /// so that their settings can be used to
        /// filter the news sources selected
        /// </summary>
        /// <returns>View</returns>
        public IActionResult Index()
        {
            // Find the user
            var user = _userSettingRepo.Read(User.Identity.Name);

            // When the user is not found
            if (user == null)
            {
                return(LocalRedirect("/Identity/Account/Register"));
            }
            else
            {
                // Create a dictionary with a key that has several attributes
                var categorySources = new Dictionary <string, List <string> >();

                // Iterate over each category
                foreach (var category in user.UserSettingNewsCategories)
                {
                    // Set the source list
                    var sourceList = new List <string>();
                    // Iterate over each source
                    foreach (var source in category.NewsSources.Select(s => s.SourceId))
                    {
                        // Add the source associated with the category to the source list
                        sourceList.Add(source);
                    }

                    // When a category at least has 1 source
                    if (sourceList.Count() > 0)
                    {
                        // Add the category and it's sources to the category source list
                        categorySources.Add(category.NewsCategory.Name, sourceList);
                    }
                }

                // Instantiate a new news list view model
                NewsListVM listVM = new NewsListVM
                {
                    UserSettingNewsCategories = user.UserSettingNewsCategories,
                    Country         = user.Country,
                    CategorySources = JsonConvert.SerializeObject(categorySources)
                };
                return(View(listVM));
            }
        }