Пример #1
0
        public ActionResult EditLinkOrderXml(FormCollection form, AddLinkViewModel objcal)
        {
            XDocument xmldoc = XDocument.Load(Server.MapPath("~/QuickLinks.xml"));
            //XElement xElement = xmldoc.XPathSelectElement("Meetings/Meeting/id[@id = '" + objcal.CalandarId + "']");

            var items = from item in xmldoc.Descendants("QuickLink")
                        where item.Element("LinkOrder").Value == objcal.LinkOrder
                        select item;

            foreach (XElement itemElement in items)
            {
                itemElement.SetElementValue("LinkOrder", objcal.LinkOrder);
                itemElement.SetElementValue("LinkTitle", objcal.LinkTitle);
                itemElement.SetElementValue("LinkAddress", objcal.LinkAddress);
            }

            xmldoc.Save(Server.MapPath("~/QuickLinks.xml"));

            return View("LinkManagerAdmin");
        }
Пример #2
0
        public ActionResult AddLinkAdmin(AddLinkViewModel model)
        {
            XDocument xmlDoc = XDocument.Load(Server.MapPath("~/QuickLinks.xml"));

             try
             {
                if (model.LinkOrder != null)
                {
                    xmlDoc.Element("QuickLinks").Add(new XElement("QuickLink",
                    new XElement("LinkOrder", model.LinkOrder),
                                                        new XElement("LinkTitle", model.LinkTitle),
                                                        new XElement("LinkAddress", model.LinkAddress )
                                                        ));
                    xmlDoc.Save(Server.MapPath("~/QuickLinks.xml"));

                    return RedirectToAction("AddLinkAdmin", "Admin", new {message = "success"});
                }
             }
             catch (Exception ex)
             {

             }

            return View();
        }