Esempio n. 1
0
        private ActionResult GetListView(int?page)
        {
            ViewBag.IsAjaxRequest = Request.IsAjaxRequest();

            var currentPageIndex = page.HasValue ? page.Value - 1 : 0;

            _songRepository.SetPaginationParams(currentPageIndex, DEFAULT_PAGE_SIZE);

            ReadOnlyCollection <Song> songs = null;

            switch (RouteData.Values["action"] as string)
            {
            case "Index":
                songs = _songRepository.GetUserSongsLocal(Config.MainAdminId, true);
                break;

            case "List":
                songs = _songRepository.GetAllSongsLocal(Config.MainAdminId, true);
                break;

            case "ByUser":
                songs = _songRepository.GetUserSongsLocal(_userId, true);
                break;
            }

            if (songs == null || songs.Count < 1)
            {
                if (Request.IsAjaxRequest())
                {
                    return(new EmptyResult());
                }

                return(GetEmptyListView(RouteData.Values["action"] as string));
            }

            return(View(RouteData.Values["action"] as string, songs));
        }