Ejemplo n.º 1
0
        /// <summary>
        /// Deletes the album with the specified <paramref name="id"/> from the system.
        /// </summary>
        /// <param name="id">
        /// The album id.
        /// </param>
        /// <returns>
        /// The view which generates page for deleting albums in case if <paramref name="id"/> was specified;
        /// otherwise redirects to the list of albums.
        /// </returns>
        public ActionResult Delete(int?id)
        {
            if (id == null || id <= 0)
            {
                return(RedirectToAction("List", "Albums", new { area = "Content" }));
            }

            var albumService = ServiceFactory.GetAlbumService();
            var album        = ManagementMapper.GetAlbumManagementViewModel(albumService.GetAlbumDetails(id.Value, CurrentUserCurrency.Code, CurrentUser.PriceLevelId));

            if (album == null)
            {
                return(HttpNotFound($"Альбом с id = {id} не найден"));
            }

            return(View(album));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="id">
        ///     The artist id.
        /// </param>
        /// <returns>
        /// </returns>
        public virtual ActionResult Edit(int id = 0)
        {
            if (id <= 0)
            {
                return(RedirectToAction("List", "Albums", new { area = "Content" }));
            }

            var albumService = ServiceFactory.GetAlbumService();
            var viewModel    = ManagementMapper.GetAlbumManagementViewModel(albumService.GetAlbumDetails(id, CurrentUserCurrency.Code, CurrentUser.PriceLevelId));

            if (viewModel == null)
            {
                return(HttpNotFound($"Альбом с id = {id} не найден"));
            }

            using (var realtionsRepo = RepositoryFactory.GetAlbumTrackRelationRepository())
            {
                var tracks = realtionsRepo.GetAll(t => t.AlbumId == id, t => t.Track).Select(t => t.Track).ToList();
                ViewBag.Tracks = tracks;
            }

            return(View(viewModel));
        }