public void DeleteUrl(string url) { mongo.RemoveUrlFromList(url);//TODOS Only 1 playlist for now as there are no users. /*SHUFFLE CODE*/ var playList = mongo.GetAllPlayLists().First(); var r = RND.Next(playList.UrlList.Count); mongo.UpdatePlayListCurrentUrl(playList.Id, playList.UrlList[r].UrlPart); /**/ Clients.All.afterDelete(playList.UrlList[r].UrlPart, url); } public void NextUrl() { //Mabey not use mongoloid function here, shape up var returnUrl = ""; var playList = mongo.GetAllPlayLists().First(); if (playList.UrlList.Count() < 2) //IF LIST IS ONLY 1 ELEMENT { returnUrl = playList.UrlList.First().UrlPart; } else //IF LIST IS SEVERAL ELEMENTS { var index = playList.UrlList.FindIndex(m => m.UrlPart == playList.CurrentUrl); try { //IF AT END OF LIST if (index + 1 >= playList.UrlList.Count()) { index = 0; returnUrl = playList.UrlList[index].UrlPart; mongo.UpdatePlayListCurrentUrl(playList.Id, returnUrl); } else { //UpdateDB ITEM index = index + 1; returnUrl = playList.UrlList[index].UrlPart; mongo.UpdatePlayListCurrentUrl(playList.Id, returnUrl); } } catch (Exception ex) { /*** Todos ***/ returnUrl = ""; }
public SyncViewModel PopulateViewModel() { var retModel = new SyncViewModel(); var playList = mongo.GetAllPlayLists().First(); var retUrlList = playList.UrlList.Select(e => new SmallerUrl() { Title = e.Title, UrlPart = e.UrlPart }); retModel.RowVersion = playList.version.ToString(); retModel.UrlCurrent = playList.CurrentUrl; retModel.isRepeat = playList.isRepeat; retModel.isShuffle = playList.isShuffle; retModel.CurrentTime = playList.time; retModel.jSonList = JsonConvert.SerializeObject(retUrlList); return(retModel); }