public ActionResult EditCV(CV cv, string id) { if (ModelState.IsValid) { var path = FileIdToPath(id); using (StreamWriter writer = new StreamWriter(path)) { XmlSerializer ser = new XmlSerializer(cv.GetType()); ser.Serialize(writer.BaseStream, cv); } return RedirectToAction("ShowCV", new { id = id }); } else { TempData["fileid"] = id; return View(cv); } }
private CV LoadFromXml(string fileId) { var path = FileIdToPath(fileId); CV cv = new CV(); using (StreamReader reader = new StreamReader(path)) { XmlSerializer serializer = new XmlSerializer(cv.GetType()); cv = serializer.Deserialize(reader.BaseStream) as CV; } return cv; }