Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            var userId = _userManager.GetUserId(User);

            if (User.Identity.IsAuthenticated)
            {
                var uDashs = await _dashboardManager.GetByUserId(userId);

                var pDashs = await _dashboardManager.GetAllPublic(userId);

                var userDashs   = _mapper.Map <IEnumerable <DashboardDto>, IEnumerable <DashboardViewModel> >(uDashs);
                var publicDashs = _mapper.Map <IEnumerable <DashboardDto>, IEnumerable <DashboardViewModel> >(pDashs);
                var result      = userDashs.Union(publicDashs);

                return(View(new DashboardIndexViewModel
                {
                    Dashboards = result.Reverse()
                }));
            }
            else
            {
                var dashboards = await _dashboardManager.GetAllPublic(userId);

                var result = _mapper.Map <IEnumerable <DashboardDto>, IEnumerable <DashboardViewModel> >(dashboards);

                return(View(new DashboardIndexViewModel
                {
                    Dashboards = result.Reverse()
                }));
            }
        }