public IActionResult Index(List <IFormFile> files) { string connectionString = _configuration.GetConnectionString("dbConnectionString"); if (files.Count == 0) { return(RedirectToAction("Index", "Home")); } foreach (var formFile in files) { using (Stream s = formFile.OpenReadStream()) { XDocument XMLDocument = XDocument.Load(s); var xmlProcessor = new ImportEmailXMLFile(XMLDocument); var processOrder = new SalesOrdersProcessor(xmlProcessor); var salesOrders = processOrder.GetSalesXMLOrders(); var salesProcessor = new DeepsnikSalesOrderSave(connectionString); var processSalesOrderSave = new SalesOrdersSaveProcessor(salesProcessor); processSalesOrderSave.RegisterSalesOrder(salesOrders.First()); } } return(RedirectToAction("Index", "Home", new { completed = true })); }
public void XMLProcessTest() { XDocument XMLDocument = XDocument.Load(@"Xml\SalesOrder.xml"); var xmlProcessor = new ImportEmailXMLFile(XMLDocument); var processOrder = new BusinessLayer.SalesOrdersProcessor(xmlProcessor); var salesOrders = processOrder.GetSalesXMLOrders(); var JSONMock = JsonConvert.SerializeObject(_mockSalesData); var JSONSales = JsonConvert.SerializeObject(salesOrders); Assert.AreEqual(JSONMock, JSONSales); }