Beispiel #1
0
        public ActionResult GetAllTechnologiesWithQuestionCount([DataSourceRequest] DataSourceRequest request)
        {
            var userEmailId = User.Identity.Name;

            if (!string.IsNullOrWhiteSpace(userEmailId))
            {
                var user = _containerUserService.FindUserByEmail(userEmailId);
                if (user != null)
                {
                    var technologies = _technologyService.GetAllTechnologies();
                    if (technologies != null && technologies.Any())
                    {
                        technologies = technologies.ToList();
                        var technologiesWithCount = _technologyService.GetAllTechnologiesWithQuestionCount(user.ID);

                        foreach (var technology in technologies)
                        {
                            int count;
                            if (technologiesWithCount.TryGetValue(technology.TechnologyId, out count))
                            {
                                technology.Count = count;
                            }
                        }
                        var technologiesViewModel = _mappingService.Map <IEnumerable <TechnologyBusinessModel>, IEnumerable <TechnologyViewModel> >(technologies);
                        return(Json(technologiesViewModel, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(null);
        }