Esempio n. 1
0
        public JsonResult GetInterests()
        {
            var indexes   = interestsUsersService.GetAllInterests(currentUser.Id).Select(e => e.Id).ToList();
            var interests = interestService.GetAll().Select(e =>
            {
                var item      = mapper.Map <InterestSelectJsonModel>(e);
                item.Selected = indexes.Contains(e.Id);
                return(item);
            }).ToList();

            return(Json(interests));
        }
Esempio n. 2
0
        public JsonResult GetInterests(int?userId)
        {
            if (userId == null)
            {
                return(Json(new List <InterestSelectJsonModel>()));
            }
            var indexes = interestsUsersService.GetAllInterests(userId.Value)
                          .Select(e => e.Id)
                          .ToList();
            var interests = interestService.GetAll().Select(e =>
            {
                var item      = mapper.Map <InterestSelectJsonModel>(e);
                item.Selected = indexes.Contains(e.Id);
                return(item);
            }).ToList();

            return(Json(interests));
        }