// GET: Album/AllAlbums
        public ActionResult AllAlbums()
        {
            var model = new AlbumSearchViewModel();

            model.SearchResults = _albumService.GetAllAlbums();
            return(View(model));
        }
        public ActionResult MyAlbums(AlbumSearchViewModel model)
        {
            var currentUser = this.Session["User"] as UserDTO;
            var userId      = currentUser.Id;

            var albums = _albumService.GetAllAlbums().Where(x => x.UserId == userId).ToList();

            model.SearchResults = albums;

            return(View(model));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> AllAlbums()
        {
            var model = new AlbumSearchViewModel();

            model.SearchResults = _albumService.GetAllAlbums();

            Response res = new Response()
            {
                ResponseCode    = HttpStatusCode.OK.ToString(),
                ResponseMessage = "Success",
                Result          = model.SearchResults
            };

            return(Ok(res));
        }
Esempio n. 4
0
        public ActionResult Index([Bind(Exclude = "AlbumArtUrl, AlbumId, ArtistId, GenreId, ImageMimeType, TrackList")]
                                  ICollection <AbstractSearch> searchCriteria)
        {
            var data = this.repository.Albums.AsQueryable()
                       //.GetQuery()
                       .ApplySearchCriterias(searchCriteria)
                       .ToArray();

            var model = new AlbumSearchViewModel()
            {
                Data           = data,
                SearchCriteria = searchCriteria
            };

            return(View(model));
        }
        //
        // GET: Album/CreateAlbum
        public ActionResult MyAlbums()
        {
            if (Session["User"] != null)
            {
                var currentUser = this.Session["User"] as UserDTO;
                var userId      = currentUser.Id;

                var model = new AlbumSearchViewModel();
                model.SearchResults = _albumService.GetAllAlbums().Where(x => x.UserId == userId).ToList();

                return(View(model));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Esempio n. 6
0
        //Search info about albums
        public ActionResult Index()
        {
            var data = this.repository.Albums.AsQueryable()
                       //.GetQuery()
                       .ToArray();

            var model = new AlbumSearchViewModel()
            {
                Data           = data,
                SearchCriteria = typeof(Album)
                                 .GetDefaultSearchCriterias(excludedProperties)
                                 .AddCustomSearchCriteria <Album>(s => s.Genre.Name)
                                 .AddCustomSearchCriteria <Album>(s => s.Artist.Name)
            };

            return(View(model));
        }
        public ActionResult AllAlbums(AlbumSearchViewModel model)
        {
            var albums = _albumService.GetAllAlbums();

            if (!string.IsNullOrWhiteSpace(model.SearchWord))
            {
                albums = albums.Where(b => b.AlbumName.ToLower().Contains(model.SearchWord.ToLower())).ToList();
            }

            if (model.CategoryId > 0)
            {
                albums = albums.Where(x => x.CategoryId == model.CategoryId).ToList();
            }

            model.SearchResults = albums;

            return(View(model));
        }
Esempio n. 8
0
        public async Task <IHttpActionResult> AllAlbums(AlbumSearchViewModel model)
        {
            var albums = _albumService.GetAllAlbums();

            if (!string.IsNullOrWhiteSpace(model.SearchWord))
            {
                albums = albums.Where(b => b.ALBUM_NAME.ToLower().Contains(model.SearchWord.ToLower())).ToList();
            }

            if (!string.IsNullOrWhiteSpace(model.SchoolCode))
            {
                albums = albums.Where(b => b.SchoolCode.ToLower().Contains(model.SchoolCode.ToLower())).ToList();
            }

            model.SearchResults = albums;
            Response res = new Response()
            {
                ResponseCode    = HttpStatusCode.OK.ToString(),
                ResponseMessage = "Success",
                Result          = model.SearchResults
            };

            return(Ok(res));
        }
Esempio n. 9
0
        //This action method only searchs on 1 criteria, using the view
        public ActionResult DefaultSearch(SearchCriteria criteria, string searchString)
        {
            string targetTypeName = "GreenSol.Domain.Entities.Album";

            IQueryable <Album> queryable = repository.Albums.AsQueryable();

            //if (criteria == SearchCriteria.Genres)
            //    queryable = repository.Genres.AsQueryable();
            //else if (criteria == SearchCriteria.Artists)
            //    queryable = repository.Artists.AsQueryable();
            //else
            //    queryable = repository.Albums.AsQueryable();

            List <AbstractSearch> searchCriteria = new List <AbstractSearch>()
            {
                //Initialize all criterias, so that the user can use the advance search
                //without being redirected to Seach/Index
                new DateSearch()
                {
                    SearchTerm     = null,
                    SearchTerm2    = null,
                    Comparator     = DateComparators.GreaterOrEqual,
                    Property       = "Date",
                    TargetTypeName = targetTypeName
                },
                //If criteria = "Genres"
                new TextSearch()
                {
                    SearchTerm = (criteria == SearchCriteria.Genres ? searchString : ""),
                    //Comparator = TextComparators.Contains,
                    Property       = "Genre.Name",
                    TargetTypeName = targetTypeName
                },
                new TextSearch()
                {
                    SearchTerm = (criteria == SearchCriteria.Titles ? searchString : ""),
                    //Comparator = TextComparators.Contains,
                    Property       = "Name",
                    TargetTypeName = targetTypeName
                },
                new TextSearch()
                {
                    SearchTerm = (criteria == SearchCriteria.Artists ? searchString : ""),
                    //Comparator = TextComparators.Contains,
                    Property       = "Artist.Name",
                    TargetTypeName = targetTypeName
                },
                new NumericSearch()
                {
                    SearchTerm     = null,
                    Comparator     = NumericComparators.GreaterOrEqual,
                    Property       = "Price",
                    TargetTypeName = targetTypeName
                }
            };

            var result = queryable.ApplySearchCriterias(searchCriteria);

            var viewModel = new AlbumSearchViewModel()
            {
                Data           = result.AsEnumerable(),
                SearchCriteria = searchCriteria
            };

            return(View("Index", viewModel));
        }
        public ActionResult Search(string phrase)
        {
            var vm = new AlbumSearchViewModel(phrase, this._musicRepository);

            return(View("Search", vm));
        }
        // GET: Albums
        public async Task <IActionResult> Index(AlbumSearchViewModel searchModel)
        {
            int?emphasisHeaderNum      = null;
            IEnumerable <Album> albums = await _context.Albums.ToListAsync();

            // get current user
            ApplicationUser currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

            if (currentUser == null)
            {
                throw new Exception("No current user.");
            }

            // filter by current owner
            albums = albums.Where(s => s.ArtistId == currentUser.Id);

            // search criteria
            if (!string.IsNullOrWhiteSpace(searchModel.SearchCriteria))
            {
                albums = albums.Where(item => item.Name.ToUpper().Contains(searchModel.SearchCriteria.ToUpper()));
            }

            // date filtering
            // start date
            if (!string.IsNullOrEmpty(searchModel.StartDate))
            {
                DateTime startDate = DateTime.Parse(searchModel.StartDate);
                albums = albums.Where(item => item.ReleaseDate.Value.CompareTo(startDate) >= 0);
            }

            // end date
            if (!string.IsNullOrEmpty(searchModel.EndDate))
            {
                DateTime endDate = DateTime.Parse(searchModel.EndDate);
                albums = albums.Where(item => item.ReleaseDate.Value.CompareTo(endDate) <= 0);
            }

            // sort order
            switch (searchModel.SortOrder)
            {
            case "album-name":
                albums            = albums.OrderBy(s => s.Name);
                emphasisHeaderNum = 0;
                break;

            case "artist":
                albums            = albums.OrderBy(s => s.ArtistName);
                emphasisHeaderNum = 1;
                break;

            // case "album-name":
            //  albums = albums.OrderBy(s => {
            //      if (s.Album != null) return s.Album.Name;
            //      else return "Unknown Album";
            //  });
            //  emphasisHeaderNum = 2;
            //  break;
            case "release-date":
                albums = albums.OrderBy(s => {
                    if (s.ReleaseDate != null)
                    {
                        return(s.ReleaseDate.Value.ToString());
                    }
                    else
                    {
                        return("");
                    }
                });
                emphasisHeaderNum = 2;
                break;

            default:
                albums = albums.OrderBy(s => s.Id);
                break;
            }

            // flip order
            if (searchModel.FlipOrder)
            {
                albums = albums.Reverse();
            }

            // pagination
            int pageNumber = (searchModel.PageNumber ?? 1);
            int pageSize   = (searchModel.PageSize ?? 10);

            IPaginator <Album> paginator = new Paginator <Album>(albums, pageSize, pageNumber);

            ViewData["paginator"]         = paginator;
            ViewData["searchSettings"]    = searchModel;
            ViewData["emphasisHeaderNum"] = emphasisHeaderNum;

            // send the paginated items to the view
            return(View(paginator.GetItems()));
        }