Exemplo n.º 1
0
        public ActionResult XMLFromData()
        {
            XmlDocument    XMLfile         = new XmlDocument();
            XmlDeclaration xml_declaration = XMLfile.CreateXmlDeclaration("1.0", "UTF-8", null);
            XmlElement     root            = XMLfile.DocumentElement;

            XMLfile.InsertBefore(xml_declaration, root);

            //XMLfile.Load(AppDomain.CurrentDomain.BaseDirectory + "/Content/XMLRepository.xml");
            XmlElement gallery = XMLfile.CreateElement("gallery");

            XMLfile.AppendChild(gallery);

            int i = 1;

            foreach (MembershipUser user in Membership.GetAllUsers())
            {
                foreach (MediaType mediaType in Enum.GetValues(typeof(MediaType)))
                {
                    foreach (MediaCollection mediaCollection in repository.GetMediaCollectionsDescriptions(user.UserName, mediaType))
                    {
                        XmlNode xmlMediaCollection = XMLfile.CreateElement("item" + i++);

                        XmlAttribute attr_userName = XMLfile.CreateAttribute("UserName");
                        attr_userName.Value = user.UserName;
                        xmlMediaCollection.Attributes.Append(attr_userName);

                        XmlAttribute attr_mediaType = XMLfile.CreateAttribute("MediaType");
                        int          _mediaType     = (int)mediaType;
                        attr_mediaType.Value = _mediaType.ToString();
                        xmlMediaCollection.Attributes.Append(attr_mediaType);

                        XmlAttribute attr_itemFolder = XMLfile.CreateAttribute("Location");
                        attr_itemFolder.Value = mediaCollection.Location;
                        xmlMediaCollection.Attributes.Append(attr_itemFolder);

                        XmlAttribute attr_itemShortTitle = XMLfile.CreateAttribute("ShortTitle");
                        attr_itemShortTitle.Value = mediaCollection.ShortTitle;
                        xmlMediaCollection.Attributes.Append(attr_itemShortTitle);

                        XmlAttribute attr_itemTitle = XMLfile.CreateAttribute("Title");
                        attr_itemTitle.Value = mediaCollection.Title;
                        xmlMediaCollection.Attributes.Append(attr_itemTitle);

                        XmlAttribute attr_itemDescription = XMLfile.CreateAttribute("Description");
                        attr_itemDescription.Value = mediaCollection.Description;
                        xmlMediaCollection.Attributes.Append(attr_itemDescription);

                        gallery.AppendChild(xmlMediaCollection);

                        foreach (MediaElement mediaElement in repository.GetMediaCollection(mediaCollection.Id))
                        {
                            XmlNode xmlMediaElement = XMLfile.CreateElement("item");

                            XmlAttribute fileName = XMLfile.CreateAttribute("fileName");
                            fileName.Value = mediaElement.File;
                            xmlMediaElement.Attributes.Append(fileName);

                            xmlMediaCollection.AppendChild(xmlMediaElement);
                        }
                    }
                }
            }

            XMLfile.Save(AppDomain.CurrentDomain.BaseDirectory + "/Content/XMLRepository.xml");
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 //UNDER CONSTRUCTION
 public ActionResult List()
 {
     return(View(repository.GetMediaCollectionsDescriptions(UserName: "******", MediaType: MediaType.Video)));
 }
Exemplo n.º 3
0
 public ActionResult CollectionsList()
 {
     ViewBag.User = this.User.Identity.Name.ToString();
     return(View(repository.GetMediaCollectionsDescriptions(UserName: User.Identity.Name, MediaType: MediaType.Photo).ToList()));
 }