コード例 #1
0
        public ActionResult AddToQueue(JsonSong song)
        {
            object json = new { message = "ok" };

            if (User != null && User is FacebookPrincipal && (User as FacebookPrincipal).IsInRole("Triphulcas"))
            {
                bool       found = false;
                Document[] temas = GetTemasInGramola();
                foreach (var tema in temas)
                {
                    if (tema.getProperty("songID").Value.ToString() == song.SongID)
                    {
                        found = true;
                        json  = new { message = "already in queue" };
                        break;
                    }
                }
                if (!found)
                {
                    var currentUser = User as FacebookPrincipal;
                    var memberId    = currentUser.GetMember().Id;

                    RelationType type    = RelationType.GetByAlias("userSongs");
                    DocumentType docType = DocumentType.GetByAlias("Tema");
                    var          doc     = Document.MakeNew(String.Format("{0}_tema_{1}_{2}", currentUser.UniqueLink, song.SongName, song.ArtistName), docType, umbraco.BusinessLogic.User.GetUser(1), 1210);//user "triphulca", parent: Gramola page
                    doc.getProperty("songID").Value     = song.SongID;
                    doc.getProperty("songName").Value   = song.SongName;
                    doc.getProperty("artistName").Value = song.ArtistName;

                    Relation.MakeNew(memberId, doc.Id, type, "new song");
                    doc.Publish(umbraco.BusinessLogic.User.GetUser(1));//user "triphulca"
                    umbraco.library.UpdateDocumentCache(doc.Id);
                }
            }

            return(Json(json, JsonRequestBehavior.DenyGet));
        }
コード例 #2
0
        public ActionResult AddToQueue(JsonSong song)
        {
            object json = new { message = "ok" };

            if (User != null && User is FacebookPrincipal && (User as FacebookPrincipal).IsInRole("Triphulcas"))
            {
                bool found = false;
                Document[] temas = GetTemasInGramola();
                foreach (var tema in temas)
                    if (tema.getProperty("songID").Value.ToString() == song.SongID) {
                        found = true;
                        json = new { message = "already in queue" };
                        break;
                    }
                if (!found)
                {
                    var currentUser = User as FacebookPrincipal;
                    var memberId = currentUser.GetMember().Id;

                    RelationType type = RelationType.GetByAlias("userSongs");
                    DocumentType docType = DocumentType.GetByAlias("Tema");
                    var doc = Document.MakeNew(String.Format("{0}_tema_{1}_{2}", currentUser.UniqueLink, song.SongName, song.ArtistName), docType, umbraco.BusinessLogic.User.GetUser(1), 1210);//user "triphulca", parent: Gramola page
                    doc.getProperty("songID").Value = song.SongID;
                    doc.getProperty("songName").Value = song.SongName;
                    doc.getProperty("artistName").Value = song.ArtistName;
                    
                    Relation.MakeNew(memberId, doc.Id, type, "new song");
                    doc.Publish(umbraco.BusinessLogic.User.GetUser(1));//user "triphulca"
                    umbraco.library.UpdateDocumentCache(doc.Id);
                }
            }

            return Json(json, JsonRequestBehavior.DenyGet);
        }