示例#1
0
        public void SaveData(int?id)
        {
            XmlSerializer     xsSubmit = new XmlSerializer(typeof(MagazineViewModel));
            MagazineViewModel magazine = _magazineService.GetMagazine(id.Value);
            var xml = "";

            using (var sww = new StringWriter())
            {
                using (XmlWriter writer = XmlWriter.Create(sww))
                {
                    xsSubmit.Serialize(writer, magazine);
                    xml = sww.ToString();

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(xml);
                    doc.Save(Server.MapPath("~/uploads/magazine.xml"));
                }
            }
            byte[] fileBytes = System.IO.File.ReadAllBytes(Server.MapPath("~/uploads/magazine.xml"));
            string fileName  = "magazine.xml";

            File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
        }
示例#2
0
 public ActionResult EditMagazine(int id)
 {
     return(View(_magazineService.GetMagazine(id)));
 }