Пример #1
0
 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);
     }
 }
Пример #2
0
        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;
        }