//----------------------------------------------------------------------------------------------------------



        //----------------------------------------------------------------------------------------------------------
        // apply order to playlist songs
        //
        //authentitication implemented inside (ajax call)
        public string applyOrder()
        {
            //--------------------------------------------------------------------------------------------
            if (User.Identity.IsAuthenticated == false)
            {
                return("not authorized");
            }
            //--------------------------------------------------------------------------------------------



            // 1.parse parameters
            //--------------------------------------------------------------------------------------------
            int  SONG_ID       = 0;
            int  SONG_ORDER    = 0;
            int  ACTIVE_PL     = 0;
            bool params_parsed = true;

            if (Request.QueryString["SONG_ID"] != null && Int32.TryParse(Request.QueryString["SONG_ID"], out SONG_ID) == false)
            {
                params_parsed = false;
            }

            if (Request.QueryString["SONG_ORDER"] != null && Int32.TryParse(Request.QueryString["SONG_ORDER"], out SONG_ORDER) == false)
            {
                params_parsed = false;
            }

            if (Request.QueryString["ACTIVE_PL"] != null && Int32.TryParse(Request.QueryString["ACTIVE_PL"], out ACTIVE_PL) == false)
            {
                params_parsed = false;
            }
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            if (params_parsed == true)
            {
                hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement();
                hypster_tv_DAL.Member           curr_user     = new hypster_tv_DAL.Member();
                curr_user = memberManager.getMemberByUserName(User.Identity.Name);


                hypster_tv_DAL.playlistManagement       playlistsManagement = new hypster_tv_DAL.playlistManagement();
                List <hypster_tv_DAL.PlaylistData_Song> songs_list          = new List <hypster_tv_DAL.PlaylistData_Song>();
                songs_list = playlistsManagement.GetSongsForPlayList(curr_user.id, ACTIVE_PL);



                int UPD_INDEX = -1;
                int i_count   = 0;
                hypster_tv_DAL.PlaylistData_Song i_currSong = new hypster_tv_DAL.PlaylistData_Song();



                //2. find position of where new link will be located
                //**************************************************************************************************************************
                i_count = 0;
                foreach (hypster_tv_DAL.PlaylistData_Song item in songs_list)
                {
                    if (item.playlist_track_id == SONG_ID)
                    {
                        int add_ind = 0;
                        if (SONG_ORDER > 0)
                        {
                            add_ind = 1;
                        }


                        UPD_INDEX  = i_count + SONG_ORDER + add_ind;
                        i_currSong = item;

                        break;
                    }

                    i_count++;
                }
                //**************************************************************************************************************************



                bool update_order = false;


                //3. get to position of new element and start updating new order
                //**************************************************************************************************************************
                List <hypster_tv_DAL.PlaylistData_Song> upd_links_arr = new List <hypster_tv_DAL.PlaylistData_Song>();
                i_count = 0;
                foreach (hypster_tv_DAL.PlaylistData_Song ii_item in songs_list)
                {
                    //inc next items order
                    if (update_order == true)
                    {
                        if (ii_item.playlist_track_id != SONG_ID)
                        {
                            ii_item.sortid += 1;
                            upd_links_arr.Add(ii_item);
                        }
                    }


                    //find start element
                    if (UPD_INDEX == i_count)
                    {
                        i_currSong.sortid = ii_item.sortid;
                        upd_links_arr.Add(i_currSong);
                        update_order = true;


                        ii_item.sortid += 1;
                        upd_links_arr.Add(ii_item);
                    }


                    i_count++;
                }
                playlistsManagement.Update_CustomOrder(curr_user.id, upd_links_arr);
                //**************************************************************************************************************************
            }
            //--------------------------------------------------------------------------------------------



            return("true");
        }