public ActionResult Index(string type) { SaveCareerType(type); FactFindViewModel model = new FactFindViewModel(); var xmldoc = new XmlDataDocument(); XmlNodeList xmlnode; XmlNode node; string path = HttpContext.Server.MapPath("~/App_Data/FactFind.xml"); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); xmldoc.Load(fs); fs.Close(); fs.Dispose(); node = xmldoc.SelectSingleNode("StudentId"); xmlnode = xmldoc.GetElementsByTagName("StudentId"); Guid studentId = Guid.Parse(xmlnode[0].InnerText); model.Asset = xmldoc.GetElementsByTagName("Asset")[0].InnerXml; model.Expenditure = xmldoc.GetElementsByTagName("Expenditure")[0].InnerXml; model.Income = xmldoc.GetElementsByTagName("Income")[0].InnerXml; model.Liablity = xmldoc.GetElementsByTagName("Liablity")[0].InnerXml; return(View(model)); }
public ActionResult FactFind(FactFindViewModel model) { System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(FactFindViewModel)); string path = HttpContext.Server.MapPath("~/App_Data/FactFind.xml"); System.IO.FileStream file = System.IO.File.Create(path); writer.Serialize(file, model); file.Close(); return(RedirectToAction("Index", "FinancialRecommendation")); }
public ActionResult Index() { var model = new FactFindViewModel(); var xmldoc = new XmlDataDocument(); ViewData["Selected"] = "Domestic"; XmlNodeList xmlnode; XmlNodeList xmlcareer; string path = HttpContext.Server.MapPath("~/App_Data/FactFind.xml"); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); xmldoc.Load(fs); fs.Close(); fs.Dispose(); xmlnode = xmldoc.GetElementsByTagName("StudentId"); model.Asset = xmldoc.GetElementsByTagName("Asset")[0].InnerXml; model.Expenditure = xmldoc.GetElementsByTagName("Expenditure")[0].InnerXml; model.Income = xmldoc.GetElementsByTagName("Income")[0].InnerXml; model.Liablity = xmldoc.GetElementsByTagName("Liablity")[0].InnerXml; path = HttpContext.Server.MapPath("~/App_Data/Career.xml"); xmldoc = new XmlDataDocument(); fs = new FileStream(path, FileMode.Open, FileAccess.Read); xmldoc.Load(fs); fs.Close(); fs.Dispose(); xmlcareer = xmldoc.GetElementsByTagName("career"); var academic = xmldoc.GetElementsByTagName("academic")[0].InnerXml; var nonAcademic = xmldoc.GetElementsByTagName("nonacademic")[0].InnerXml; academic = academic.Replace(" ", ""); nonAcademic = nonAcademic.Replace(" ", ""); path = HttpContext.Server.MapPath("~/App_Data/Domestic.xml"); xmldoc = new XmlDataDocument(); fs = new FileStream(path, FileMode.Open, FileAccess.Read); xmldoc.Load(fs); fs.Close(); fs.Dispose(); var currentAcademicCost = xmldoc.GetElementsByTagName(academic)[0].InnerXml; var currentNonAcademicCost = xmldoc.GetElementsByTagName(nonAcademic)[0].InnerXml; path = HttpContext.Server.MapPath("~/App_Data/Careertype.xml"); xmldoc = new XmlDataDocument(); fs = new FileStream(path, FileMode.Open, FileAccess.Read); xmldoc.Load(fs); fs.Close(); fs.Dispose(); xmlcareer = xmldoc.GetElementsByTagName("Career"); var academictype = xmldoc.GetElementsByTagName("Type")[0].InnerXml; var costtocalculate = (academictype == "Academic" ? currentAcademicCost : currentNonAcademicCost); var AspirationCost = financialService.FutureCost(Convert.ToDecimal(costtocalculate), 8, 7); var assestCost = financialService.FutureCost(Convert.ToDecimal(model.Asset), 8, 7); var financialModel = new FinancialViewModel(); financialModel.ActualCost = assestCost; financialModel.ProjectedCost = AspirationCost; financialModel.Years = 7; financialModel.ShortFall = AspirationCost - assestCost; System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(FinancialViewModel)); path = HttpContext.Server.MapPath("~/App_Data/FinancialRecommendation.xml"); System.IO.FileStream file = System.IO.File.Create(path); writer.Serialize(file, financialModel); file.Close(); return(View()); }