예제 #1
0
파일: SongService.cs 프로젝트: Lavsiant/MFA
        public async Task <List <Song> > GetFilteredSongs(State state, Genre genre)
        {
            var songs = await _songRepository.GetAllSongs();

            if (genre != Genre.Undefined)
            {
                songs = songs.Where(x => x.Genre == genre).ToList();
            }

            if (state != null)
            {
                if (state.Location != Location.Undefined)
                {
                    songs = songs.Where(x => x.State.Location == state.Location).ToList();
                }
                if (state.Mood != Mood.Undefined)
                {
                    songs = songs.Where(x => x.State.Mood == state.Mood).ToList();
                }
                if (state.Weather != Weather.Undefined)
                {
                    songs = songs.Where(x => x.State.Weather == state.Weather).ToList();
                }
            }

            return(songs);
        }
예제 #2
0
        private ActionResult GetListView(int?page)
        {
            var currentPageIndex = page.HasValue ? page.Value - 1 : 0;

            _songRepository.SetPaginationParams(currentPageIndex, DEFAULT_PAGE_SIZE);

            var songCount = 0L;
            ReadOnlyCollection <Song> songs = null;

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

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

            case "ByUser":
                songCount = _songRepository.CountUserSongs(_userId);
                songs     = _songRepository.GetUserSongs(_userId, true);
                break;

            case "ByDeletedUsers":
                songCount = _songRepository.CountSongsByDeletedUsers();
                songs     = _songRepository.GetSongsByDeletedUsers(true);
                break;
            }

            return(View(RouteData.Values["action"] as string, songs.ToPagedList(currentPageIndex, DEFAULT_PAGE_SIZE, songCount)));
        }
예제 #3
0
        public List <Song> GetAllSongs()
        {
            List <Song>             songs         = new List <Song>();
            CoreToDataMapperService mapperService = new CoreToDataMapperService();

            foreach (ISong songData in _songRepository.GetAllSongs())
            {
                songs.Add(mapperService.MapSongDataToCore(songData));
            }
            return(songs);
        }
예제 #4
0
        public async Task <ViewResult> GetAllSongs(bool isSuccess, int?songId)

        {
            //var userId = _userManager.GetUserId(this.HttpContext.User);
            var datas = await _songRepository.GetAllSongs();

            ViewBag.IsSuccess = TempData["Alert"];
            ViewBag.SongId    = TempData["SongID"];
            //isSuccess = false;
            TempData["Alert"]  = false;
            TempData["SongID"] = 0;

            foreach (var data in datas)
            {
                data.CalculateTime = _songRepository.CalculateTime(data.CreatedOn.GetValueOrDefault());
            }

            return(View(datas));
            //return RedirectToAction(datas, new { isSuccess = true, songId = datas.Count() });
        }
예제 #5
0
        public ViewResult Index2()
        {
            var model = _songRepository.GetAllSongs();

            return(View(model));
        }
예제 #6
0
        //
        // GET: /Song/

        public ViewResult Index()
        {
            return(View(songRepository.GetAllSongs(song => song.Album)));
        }
예제 #7
0
        public IActionResult Index()
        {
            var songs = repo.GetAllSongs();

            return(View(songs));
        }