Exemplo n.º 1
0
        private List <StatisticViewModel> GetStatisticViewModels()
        {
            List <StatisticViewModel> result = new List <StatisticViewModel>();

            LanguagesRepository             languagesRepository             = new LanguagesRepository();
            LanguagesTranslationsRepository languagesTranslationsRepository = new LanguagesTranslationsRepository();
            IEnumerable <Languages>         languages = languagesRepository.GetAll();
            List <int> languagesId = languages.Select(l => l.Id).ToList();
            List <CategoryStatistic> categoryStatistics = FillCategory();

            foreach (var languageId in languagesId)
            {
                IEnumerable <LanguageTranslations> languageTranslationsList = languagesTranslationsRepository.GetAll();
                var    id       = languageId;
                string langName = languageTranslationsList
                                  .First(l => l.LangId == id && l.NativeLangId == _userLanguageId).Translation;
                List <CategoryStatistic> listToCopy = Helper.DeepClone(categoryStatistics);
                result.Add(new StatisticViewModel
                {
                    LanguageName       = langName,
                    CategoryStatistics = listToCopy,
                    LanguageId         = languageId
                });
            }
            StatisticViewModel[] statisticArray = new StatisticViewModel[result.Count];
            for (int j = 0; j < statisticArray.Length; j++)
            {
                statisticArray[j] = FillResults(result[j]);
            }

            return(result);
        }
        public IActionResult Languages()
        {
            IRepository <Languages> languagesRepository = new LanguagesRepository();
            List <Languages>        languagesList       = languagesRepository.GetAll().ToList();
            SelectList languages = new SelectList(languagesList, "Id", "Name");

            return(View(languages));
        }
Exemplo n.º 3
0
        public JsonResult Get()
        {
            var modelList = _repository.GetAll();

            return(Json(modelList));
        }