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); }
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))); }
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); }
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() }); }
public ViewResult Index2() { var model = _songRepository.GetAllSongs(); return(View(model)); }
// // GET: /Song/ public ViewResult Index() { return(View(songRepository.GetAllSongs(song => song.Album))); }
public IActionResult Index() { var songs = repo.GetAllSongs(); return(View(songs)); }