public override void SetUp() { mConfig = new mConfig(); configSection = new XmlDocument(); //an xml declaration is needed to be treated as xml, but the xml section that is passed to mConfig.Create() in //actual use is missing it. // XmlDeclaration xmlDeclaration = configSection.CreateXmlDeclaration("1.0", "utf-8", null); // configSection.InsertBefore(xmlDeclaration, configSection.DocumentElement); XmlElement root = configSection.CreateElement("m"); configSection.AppendChild(root); XmlElement element1 = configSection.CreateElement("MusicDirectory"); root.AppendChild(element1); element1.AppendChild(configSection.CreateTextNode("Directory One")); XmlElement element2 = configSection.CreateElement("MusicDirectory"); root.AppendChild(element2); element2.AppendChild(configSection.CreateTextNode("Directory Two")); XmlElement element3 = configSection.CreateElement("MusicDirectory"); root.AppendChild(element3); element3.AppendChild(configSection.CreateTextNode("Directory Three")); XmlElement element4 = configSection.CreateElement("SomeOtherElement"); root.AppendChild(element4); element4.AppendChild(configSection.CreateTextNode("Not a directory")); }
public ActionResult NewOrEdit(mConfig model, FormCollection frm) { try { var db = DB.Entities; if (model.ID == 0) { db.mConfig.AddObject(model); } else { db.AttachTo("mConfig", model); db.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified); } db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }