Esempio n. 1
0
        public IActionResult Profile()
        {
            ViewBag.title = "Profile";


            ViewBag.LastTopics     = topicService.GetLastTopics();
            ViewBag.TrendingTopics = topicService.GetTrendingTopics();


            string id       = User.Claims.FirstOrDefault(y => y.Type == "user_id").Value;
            string username = User.Claims.FirstOrDefault(y => y.Type == "name").Value;

            aiService.TrackUser("ViewProfile", id);

            var user = userService.FindUserById(id);

            if (user == null)
            {
                user          = new User();
                user.Id       = id;
                user.username = username;
                return(View(user));
            }
            else
            {
                if (!string.IsNullOrEmpty(user.topics))
                {
                    user.tags = Newtonsoft.Json.JsonConvert.DeserializeObject <List <string> >(user.topics);
                }
                return(View(user));
            }
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            try
            {
                string username = User.Claims.FirstOrDefault(y => y.Type == "user_id").Value;
                var    user     = userService.FindUserById(username);
                aiService.TrackUser("Homepage", username);
                if (user == null || string.IsNullOrEmpty(user.topics))
                {
                    ViewBag.user = string.Empty;
                }
                else
                {
                    ViewBag.user = user.Id;
                }

                ViewBag.title          = "Home";
                ViewBag.LastTopics     = topicService.GetLastTopics();
                ViewBag.TrendingTopics = topicService.GetTrendingTopics();
            }
            catch (Exception ex)
            {
                aiService.TrackException(ex);
            }
            return(View());
        }