public async Task <IActionResult> Delete(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var album = await _dbContext.Albums.FindAsync(id);

            if (album == null)
            {
                return(NotFound());
            }

            var model = new AlbumsViewModel()
            {
                Id            = album.Id,
                Name          = album.Name,
                PerformerId   = album.PerformerId,
                PerformerName = (await _dbContext.Performers.FindAsync(album.PerformerId)).Name,
                DateOfRelease = album.DateOfRelease
            };

            return(View(model));
        }
Beispiel #2
0
        // GET: Albums/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var album = await _context.Albums.FirstOrDefaultAsync(a => a.Id == id);

            if (album == null)
            {
                return(NotFound());
            }

            var allPhotos = await _context.Photos
                            .OrderByDescending(p => p.Id).ToListAsync();

            var photos = await _context.AlbumPhotos
                         .Where(ap => ap.Album.Id == album.Id)
                         .Select(ap => ap.Photo.Id)
                         .ToListAsync();

            var model = new AlbumsViewModel {
                Album     = album,
                Photos    = photos,
                AllPhotos = allPhotos
            };

            return(View(model));
        }
        // GET: Admin/Albums
        public async Task <IActionResult> Index(int?genreID, int?artistID, string titleFilter)
        {
            var storeContext = _context.Albums.Include(a => a.Artist).Include(a => a.Genre).OrderBy(a => a.Artist.Name).ToList();


            if (genreID != null && genreID != 0)
            {
                storeContext = storeContext.Where(a => a.GenreID == genreID).OrderBy(a => a.Title).ToList();
            }
            if (artistID != null && artistID != 0)
            {
                storeContext = storeContext.Where(a => a.ArtistID == artistID).OrderBy(a => a.Title).ToList();
            }
            if (titleFilter != null)
            {
                storeContext = storeContext.Where(a => a.Title.ToUpper().Contains(titleFilter.ToUpper())).OrderBy(a => a.Title).ToList();
            }

            var listAlbumsVM = new AlbumsViewModel();

            listAlbumsVM.ListAlbums  = storeContext;
            listAlbumsVM.Genres      = new SelectList(_context.Genres.OrderBy(g => g.Name), "GenreID", "Name");
            listAlbumsVM.Artists     = new SelectList(_context.Artists.OrderBy(a => a.Name), "ArtistID", "Name");
            listAlbumsVM.artistID    = (artistID == null) ? 0 : (int)artistID;
            listAlbumsVM.genreID     = (genreID == null) ? 0 : (int)genreID;
            listAlbumsVM.titleFilter = "";



            return(View(listAlbumsVM));
        }
Beispiel #4
0
 protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
 {
     if (ViewModels[pivot.SelectedIndex].IsSelectionEnabled == true)
     {
         e.Cancel = true;
         ViewModels[pivot.SelectedIndex].IsSelectionEnabled = false;
         pivot.IsLocked = true;
         CreateSelectionAppBar();
         return;
     }
     if (deep == 0)
     {
         base.OnBackKeyPress(e);
     }
     else
     {
         e.Cancel = true;
         deep--;
         if (pivot.SelectedIndex == 0)
         {
             ViewModels[0] = new AlbumsViewModel();
             ((pivot.SelectedItem as PivotItem).Content as CollectionControl).Initialize(ViewModels[0]);
         }
     }
 }
 public AddPicturePage()
 {
     InitializeComponent();
     UserId          = Preferences.Get("userId", -1);
     Streams         = new Dictionary <Stream, string>();
     albumsViewModel = new AlbumsViewModel(App.FilePath);
 }
Beispiel #6
0
        public ActionResult AlbumsForEditor(Guid?groupId)
        {
            if (!Request.IsAuthenticated)
            {
                throw new AuthenticationException();
            }

            var user = DataService.PerThread.BaseUserSet.OfType <User>().SingleOrDefault(x => x.Id == UserContext.Current.Id);

            if (user == null)
            {
                throw new BusinessLogicException("Перезайдите");
            }

            AlbumsViewModel model;

            if (groupId.HasValue)
            {
                var group = DataService.PerThread.GroupSet.SingleOrDefault(x => x.Id == groupId.Value);
                if (group == null)
                {
                    throw new BusinessLogicException("Указан неверный идентификатор");
                }

                model = new AlbumsViewModel(user, group);
            }
            else
            {
                model = new AlbumsViewModel(user);
            }

            return(View("albumsforeditor", "_ModalLayout", model));
        }
Beispiel #7
0
        public async Task <IActionResult> Edit(int id, AlbumsViewModel model)
        {
            if (id != model.Album.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await UpdateAlbumPhotos(model.Album, model.Photos);

                    _context.Entry(model.Album).State = EntityState.Modified;
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlbumExists(model.Album.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(model));
        }
        public IActionResult All(AlbumsViewModel model)
        {
            if (model.IsAuthenticated == "false")
            {
                model.Error = Constants.UnauthorizedAccessError;
                return(Unauthorized(model, Constants.UnauthorizedViewRoute));
            }
            var albums = AlbumService.GetAlbums();

            if (albums.Count() == 0)
            {
                model.AlbumsList = Constants.NoAlbumsMessage;
                return(View(model));
            }
            StringBuilder albumsList = new StringBuilder();

            foreach (var album in albums)
            {
                string albumsListEntry = string.Format(
                    Constants.AlbumsListEntry, album.Id, album.ToString());
                string albumsListItem = string.Format(
                    Constants.HtmlListItem, $"<b>{albumsListEntry}</b>\r\n");
                albumsList.Append(albumsListItem);
            }
            model.AlbumsList = albumsList.ToString();
            return(View(model));
        }
 public UserDataPage()
 {
     InitializeComponent();
     photosCollectionControl.CellSelected += photosCollectionControl_CellSelected;
     AlbumsCollectionViewModel             = new AlbumsViewModel();
     photosCollectionControl.Initialize(AlbumsCollectionViewModel);
     AlbumsCollectionViewModel.Initialize(cts.Token, false);
 }
 public UploadPage()
 {
     InitializeComponent();
     Privacy.SelectedIndex = 1;
     Streams         = new Dictionary <Stream, string>();
     userId          = Preferences.Get("userId", 1);
     albumsViewModel = new AlbumsViewModel(App.FilePath);
 }
Beispiel #11
0
        public IViewComponentResult Invoke()
        {
            var model = new AlbumsViewModel()
            {
                Albums = GetAlbums()
            };

            return(View(model));
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            _albumsViewModel = (AlbumsViewModel)DataContext;
            _albumsViewModel.AlbumsLoaded += this.OnAlbumsLoaded_AlignLookups;

            var root = (UserControl)sender;

            _lookupSize = root.ActualWidth;
        }
 public AlbumsPage()
 {
     InitializeComponent();
     _vm = new AlbumsViewModel()
     {
         Navigation = this.Navigation
     };
     BindingContext = _vm;
 }
Beispiel #14
0
        public async Task CheckVMInit()
        {
            var vm = new AlbumsViewModel(_navigationServiceMock.Object, _databaseServiceMock.Object, _dialogServiceMock.Object);

            vm.Prepare();
            await vm.Initialize();

            Assert.True(vm.Albums.ElementAt(0).Name == "cats");
        }
 public AlbumPage()
 {
     InitializeComponent();
     BindingContext = albumsViewModel = new AlbumsViewModel(App.FilePath);
     MessagingCenter.Subscribe <AddAlbum>(this, "CreateAlbumPopupClosed", (sender) =>
     {
         populateGrid();
     });
 }
        private AlbumsViewModel GetBaseAlbumsViewModel(int categoryID)
        {
            var viewModel = new AlbumsViewModel
            {
                Albums     = AlbumService.GetAlbumsByCategoryID(categoryID),
                CategoryID = categoryID
            };

            return(viewModel);
        }
Beispiel #17
0
        public IActionResult All()
        {
            ICollection <Album> albums = this.albumsService.GetAllAlbums(this.Identity.Username);
            AlbumsViewModel     avm    = new AlbumsViewModel {
                Albums = albums
            };

            this.ViewModel.Data["AlbumsViewModel"] = avm;
            return(this.View("all-user-albums"));
        }
Beispiel #18
0
 public IActionResult All(AlbumsViewModel model)
 {
     model.Albums = AlbumService.GetAlbums()
                    .Select(a => new AlbumViewModel()
     {
         AlbumId   = a.Id.ToString(),
         AlbumName = a.ToString()
     });
     model.HasAlbums = model.Albums.Any();
     return(View(model));
 }
Beispiel #19
0
        public MainPage()
        {
            InitializeComponent();

            _vm             = (Application.Current as App).Container.GetService <AlbumsViewModel>();
            _vm.AddCommand  = new RelayCommand(o => Frame.Navigate(typeof(EditPage)));
            _vm.EditCommand = new RelayCommand(o => Frame.Navigate(typeof(EditPage), List.SelectedItem), o => List.SelectedItem != null);
            _vm.LoadAlbums();

            DataContext = _vm;
        }
Beispiel #20
0
        // GET: Albums/Create
        public async Task <IActionResult> Create()
        {
            var allPhotos = await _context.Photos.OrderByDescending(p => p.Id).ToListAsync();

            var model = new AlbumsViewModel {
                Album     = new Album(),
                Photos    = new List <int>(),
                AllPhotos = allPhotos
            };

            return(View(model));
        }
        public async Task <ActionResult> Index()
        {
            _typiCodeService = new TypiCodeService(Client);
            var albums = await _typiCodeService.GetAlbumsAsync();

            var albumsViewModel = new AlbumsViewModel
            {
                Albums = albums
            };

            return(View(albumsViewModel));
        }
Beispiel #22
0
        public AlbumsPage()
        {
            InitializeComponent();

            SupportedOrientations = SupportedPageOrientation.Portrait;
            Loaded += new RoutedEventHandler(MainPage_Loaded);

            PageTransitionList.Completed += new EventHandler(PageTransitionList_Completed);

            // Set the data context of the listbox control to the album list
            DataContext = new AlbumsViewModel();
        }
Beispiel #23
0
        public IActionResult Albums()
        {
            var             albums = albumService.GetAll(currentUser.Id);
            AlbumsViewModel model  = new AlbumsViewModel()
            {
                CanEdit       = true,
                Album         = albums.Select(e => mapper.Map <AlbumDomainModel>(e)).ToList(),
                AddAlbumModel = new AddAlbumModel()
            };

            return(View(model));
        }
Beispiel #24
0
        private void InitializeViewModels()
        {
            ViewModels = new ObservableCollection <ViewModel>();
            var albumsModel = new AlbumsViewModel();

            albumsModel.IsSelectionEnabled = false;
            albumsModel.Initialize(cts.Token);
            var contactsModel = new ContactsViewModel();

            contactsModel.IsSelectionEnabled = true;
            contactsModel.Initialize(cts.Token);
            ViewModels.Add(albumsModel);
            ViewModels.Add(contactsModel);
        }
        public async Task <IActionResult> Index()
        {
            var items = await _AlbumsItemService.GetIncompleteItemsAsync();

            // Get to-do items from database
            // Put items into a model
            // Pass the view to a model and render
            var model = new AlbumsViewModel()
            {
                Items = items
            };

            return(View(model));
        } //[ValidateAntiForgeryToken]
Beispiel #26
0
        public async Task <IActionResult> Create(AlbumsViewModel model)
        {
            if (ModelState.IsValid)
            {
                await UpdateAlbumPhotos(
                    album : model.Album,
                    photos : model.Photos);

                _context.Albums.Add(model.Album);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
Beispiel #27
0
        public IActionResult AddAlbum(AddAlbumModel model)
        {
            if (ModelState.IsValid)
            {
                int albumId = albumService.AddAlbum(model.Name);
                return(RedirectToAction("Album", "Profile", new { albumId }));
            }
            var             albums    = albumService.GetAll(currentUser.Id);
            AlbumsViewModel modelEdit = new AlbumsViewModel()
            {
                CanEdit       = true,
                Album         = albums.Select(e => mapper.Map <AlbumDomainModel>(e)).ToList(),
                AddAlbumModel = model
            };

            return(View("Albums", modelEdit));
        }
Beispiel #28
0
        public async Task <IActionResult> List(string searchString, int pageNumber = 1)
        {
            var allAlbums = await _service.SearchAlbums(searchString);

            var skipItems = (pageNumber - 1) * Constants.DefaultPageSize;
            var albumPage = allAlbums.Skip(skipItems).Take(Constants.DefaultPageSize).ToList();

            var photosOfAlbumsDictionary = await _service.GetPhotosForAlbums(albumPage.Select(t => t.Key));

            var albumUserViewModelList = new List <AlbumUserViewModel>();

            foreach (var albumItem in albumPage)
            {
                var albumUserModel = new AlbumUserViewModel()
                {
                    Id           = albumItem.Key.Id,
                    AlbumTitle   = albumItem.Key.Title,
                    Address      = albumItem.Value?.Address ?? new Address(),
                    Email        = albumItem.Value?.Email ?? string.Empty,
                    Phone        = albumItem.Value?.Phone ?? string.Empty,
                    UserId       = albumItem.Value?.Id ?? 0,
                    UserName     = albumItem.Value?.Name ?? string.Empty,
                    ThumbnailUrl = photosOfAlbumsDictionary.ContainsKey(albumItem.Key.Id)
                        ? photosOfAlbumsDictionary[albumItem.Key.Id].FirstOrDefault()?.ThumbnailUrl : string.Empty
                };
                albumUserViewModelList.Add(albumUserModel);
            }

            var albumsViewModel = new AlbumsViewModel()
            {
                AlbumsUserViewModel = albumUserViewModelList,
                PagingData          = new PagingData()
                {
                    CurrentPage  = pageNumber,
                    ItemsPerPage = Constants.DefaultPageSize,
                    TotalItems   = allAlbums.Count()
                }
            };

            ViewBag.searchString = searchString;

            return(View(albumsViewModel));
        }
 public void Dispose()
 {
     if (SpotlightViewModel != null)
     {
         SpotlightViewModel.Dispose();
     }
     if (MoviesViewModel != null)
     {
         MoviesViewModel.Dispose();
     }
     if (SeriesViewModel != null)
     {
         SeriesViewModel.Dispose();
     }
     if (EpisodesViewModel != null)
     {
         EpisodesViewModel.Dispose();
     }
     if (GamesViewModel != null)
     {
         GamesViewModel.Dispose();
     }
     if (AlbumsViewModel != null)
     {
         AlbumsViewModel.Dispose();
     }
     if (SongsViewModel != null)
     {
         SongsViewModel.Dispose();
     }
     if (ArtistsViewModel != null)
     {
         ArtistsViewModel.Dispose();
     }
     if (MiniSpotlightsViewModel != null)
     {
         MiniSpotlightsViewModel.Dispose();
     }
     if (MiniSpotlightsViewModel2 != null)
     {
         MiniSpotlightsViewModel2.Dispose();
     }
 }
Beispiel #30
0
        public async Task <ActionResult> Index(string userId = null)
        {
            UserInfo albumUser = await GetUserInfoAsync(userId);

            if (albumUser == null)
            {
                return(HttpNotFound());
            }

            var vm = new AlbumsViewModel
            {
                UserId                = UserId,
                AlbumOwnerId          = userId,
                FullName              = albumUser.Name,
                PosessiveInformalName = UserOperations.GetInformalPosessiveName(albumUser),
                AvatarUrl             = UserOperations.GetAvatarUrl(albumUser),
                Albums                = await AlbumOperations.GetAlbumSummariesAsync(DbContext, albumUser)
            };

            return(View("Index", vm));
        }
        public async Task <IActionResult> Index(string searchName)
        {
            var allAlbums = _dbContext.Albums.ToList();

            allAlbums = allAlbums.OrderBy(x => x.Name).ToList();

            if (searchName != null && searchName != "")
            {
                allAlbums = allAlbums.Where(x => x.Name.Contains(searchName)).ToList();
            }

            var model = new AlbumsAllViewModel()
            {
                Albums = new List <AlbumsViewModel>()
            };



            foreach (var album in allAlbums)
            {
                int    songNumber    = _dbContext.Songs.Where(x => x.AlbumId == album.Id).Count();
                string performerName = (await _dbContext.Performers.FindAsync(album.PerformerId)).Name;

                var singleViewModel = new AlbumsViewModel()
                {
                    Id            = album.Id,
                    Name          = album.Name,
                    PerformerId   = album.PerformerId,
                    PerformerName = performerName,
                    SongsNumber   = songNumber
                };

                model.Albums.Add(singleViewModel);
            }

            return(View(model));
        }
 public override void Load()
 {
     if (DataContext == null)
     {
         DataContext = new AlbumsViewModel();
         ((AlbumsViewModel)DataContext).LoadAlbums();
     }
 }