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); }
public ActionResult EditMagazine(int id) { return(View(_magazineService.GetMagazine(id))); }