public ActionResult UpdateMultiple(List <PlaylistItemDto> playlistItemDtos)
        {
            List <PlaylistItemDto> savedPlaylistItemDtos;

            int count = playlistItemDtos.Count;

            if (count > 1000)
            {
                Session.SetBatchSize(count / 10);
            }
            else if (count > 3)
            {
                Session.SetBatchSize(count / 3);
            }

            using (ITransaction transaction = Session.BeginTransaction())
            {
                List <PlaylistItem> playlistItems = PlaylistItem.Create(playlistItemDtos, PlaylistManager);

                PlaylistItemManager.Update(playlistItems);

                savedPlaylistItemDtos = PlaylistItemDto.Create(playlistItems);

                transaction.Commit();
            }

            return(Json(savedPlaylistItemDtos));
        }
        public JsonResult CreateMultiple(List <PlaylistItemDto> playlistItemDtos)
        {
            List <PlaylistItemDto> savedPlaylistItemDtos;

            int count = playlistItemDtos.Count;

            if (count > 1000)
            {
                Session.SetBatchSize(count / 10);
            }
            else if (count > 3)
            {
                Session.SetBatchSize(count / 3);
            }

            using (ITransaction transaction = Session.BeginTransaction())
            {
                List <PlaylistItem> playlistItems = PlaylistItem.Create(playlistItemDtos, PlaylistManager);

                //  Split items into their respective playlists and then save on each.
                foreach (var playlistGrouping in playlistItems.GroupBy(i => i.Playlist))
                {
                    List <PlaylistItem> groupingItems = playlistGrouping.ToList();
                    playlistGrouping.Key.AddItems(groupingItems);
                    PlaylistItemManager.Save(groupingItems);
                }

                savedPlaylistItemDtos = PlaylistItemDto.Create(playlistItems);

                transaction.Commit();
            }

            return(Json(savedPlaylistItemDtos));
        }
Example #3
0
        public ActionResult UpdateMultiple(List <PlaylistItemDto> playlistItemDtos)
        {
            List <PlaylistItem> playlistItems = PlaylistItem.Create(playlistItemDtos);

            PlaylistItemManager.Update(playlistItems);

            List <PlaylistItemDto> savedPlaylistItemDtos = PlaylistItemDto.Create(playlistItems);

            return(new JsonDataContractActionResult(savedPlaylistItemDtos));
        }
Example #4
0
        public ActionResult Update(PlaylistItemDto playlistItemDto)
        {
            PlaylistItem playlistItem = PlaylistItem.Create(playlistItemDto);

            PlaylistItemManager.Update(playlistItem);

            PlaylistItemDto updatedPlaylistItemDto = PlaylistItemDto.Create(playlistItem);

            return(new JsonDataContractActionResult(updatedPlaylistItemDto));
        }
        public ActionResult Update(PlaylistItemDto playlistItemDto)
        {
            PlaylistItem playlistItem = PlaylistItem.Create(playlistItemDto);

            PlaylistItemManager.Update(playlistItem);

            PlaylistItemDto updatedPlaylistItemDto = PlaylistItemDto.Create(playlistItem);

            return(new JsonServiceStackResult(updatedPlaylistItemDto));
        }
Example #6
0
        public JsonDataContractActionResult Create(PlaylistItemDto playlistItemDto)
        {
            PlaylistItem playlistItem = PlaylistItem.Create(playlistItemDto);

            playlistItem.Playlist.AddItem(playlistItem);

            PlaylistItemManager.Save(playlistItem);

            PlaylistItemDto savedPlaylistItemDto = PlaylistItemDto.Create(playlistItem);

            return(new JsonDataContractActionResult(savedPlaylistItemDto));
        }
        public JsonServiceStackResult Create(PlaylistItemDto playlistItemDto)
        {
            PlaylistItem playlistItem = PlaylistItem.Create(playlistItemDto);

            playlistItem.Playlist.AddItem(playlistItem);

            PlaylistItemManager.Save(playlistItem);

            PlaylistItemDto savedPlaylistItemDto = PlaylistItemDto.Create(playlistItem);

            return(new JsonServiceStackResult(savedPlaylistItemDto));
        }
        public ActionResult Update(PlaylistItemDto playlistItemDto)
        {
            PlaylistItemDto updatedPlaylistItemDto;

            using (ITransaction transaction = Session.BeginTransaction())
            {
                PlaylistItem playlistItem = PlaylistItem.Create(playlistItemDto, PlaylistManager);
                PlaylistItemManager.Update(playlistItem);

                updatedPlaylistItemDto = PlaylistItemDto.Create(playlistItem);
                transaction.Commit();
            }

            return(Json(updatedPlaylistItemDto));
        }
        public JsonResult Create(PlaylistItemDto playlistItemDto)
        {
            PlaylistItemDto savedPlaylistItemDto;

            using (ITransaction transaction = Session.BeginTransaction())
            {
                PlaylistItem playlistItem = PlaylistItem.Create(playlistItemDto, PlaylistManager);

                playlistItem.Playlist.AddItem(playlistItem);

                PlaylistItemManager.Save(playlistItem);

                savedPlaylistItemDto = PlaylistItemDto.Create(playlistItem);

                transaction.Commit();
            }

            return(Json(savedPlaylistItemDto));
        }
Example #10
0
        public JsonDataContractActionResult CreateMultiple(List <PlaylistItemDto> playlistItemDtos)
        {
            List <PlaylistItem> playlistItems = PlaylistItem.Create(playlistItemDtos);

            //  Split items into their respective playlists and then save on each.
            foreach (var playlistGrouping in playlistItems.GroupBy(i => i.Playlist))
            {
                List <PlaylistItem> groupingItems = playlistGrouping.ToList();

                Playlist playlist = groupingItems.First().Playlist;
                playlist.AddItems(groupingItems);

                PlaylistItemManager.Save(groupingItems);
            }

            List <PlaylistItemDto> savedPlaylistItemDtos = PlaylistItemDto.Create(playlistItems);

            return(new JsonDataContractActionResult(savedPlaylistItemDtos));
        }