/// <summary> /// Loading of grid row elements. Default columns are parsed; if they contain any information, /// it is added as a property to PurchaseOrderReceived object. Objects are contained in /// _poRecLineItems. /// </summary> /// <returns>Current page object.</returns> internal POInboxPage LoadGridRows() { _poRecLineItems = new List <PurchaseOrderReceived>(); _poRecCheckboxes = _driver.FindElements(By.XPath(Constants.POMailbox.XP.PO_CHECKBOXES)); _poRecStatuses = _driver.FindElements(By.XPath(Constants.POMailbox.XP.PO_STATUSES)); _poRecSenderNames = _driver.FindElements(By.XPath(Constants.POMailbox.XP.PO_SENDER_NAMES)); _poRecShipToNames = _driver.FindElements(By.XPath(Constants.POMailbox.XP.PO_SHIP_TOS)); _poRecPONumbers = _driver.FindElements(By.XPath(Constants.POMailbox.XP.PO_PONUMBERS)); _poRecPODates = _driver.FindElements(By.XPath(Constants.POMailbox.XP.PO_PODATES)); _poRecBillToNames = _driver.FindElements(By.XPath(Constants.POMailbox.XP.PO_BILL_TO_NAMES)); _poRecTotalAmounts = _driver.FindElements(By.XPath(Constants.POMailbox.XP.PO_TOTAL_AMOUNTS)); _poRecDateAdded = _driver.FindElements(By.XPath(Constants.POMailbox.XP.PO_DATES_ADDED)); try { _logger.Trace(" > Attempting to load PO Received grid elements..."); for (int i = 0; i < _poRecPONumbers.Count; ++i) { PurchaseOrderReceived newPO = new PurchaseOrderReceived(); newPO.Checkbox = _poRecCheckboxes[i]; newPO.Status = _poRecStatuses[i].Text; newPO.SenderName = _poRecSenderNames[i].Text; newPO.ShipToName = _poRecShipToNames[i].Text; newPO.PONumber = _poRecPONumbers[i].Text; newPO.PODate = DateTime.Parse(_poRecPODates[i].Text); newPO.BillToName = _poRecBillToNames[i].Text; newPO.TotalAmount = decimal.Parse(_poRecTotalAmounts[i].Text); newPO.DateAdded = DateTime.Parse(_poRecDateAdded[i].Text); _poRecLineItems.Add(newPO); } } catch (Exception e) { _logger.Fatal(" > Loading PO Received grid elements [FAILED]"); _logger.Error(e); _logger.Fatal("-- TEST FAILURE @ URL: '" + _driver.Url + "' --"); BaseDriverTest.TakeScreenshot("screenshot"); } if (_poRecLineItems.Any()) { _logger.Info(" > Loading of PO Received grid elements complete!"); GridLoadSuccess = true; } return(this); }
public void Handle(PurchaseOrderReceived @event) { // Invoke the shipping domain to check stock for every book using this service's own db // calculate shipping cost based on destination // if all is OK, store the shipping manifest and publish an event var totalCostWithoutShipping = @event.BooksOrdered.Sum(x => x.BookPrice); var shippingCost = totalCostWithoutShipping * 0.2m; var shippingManifest = new ShippingManifest { BookIds = String.Join(", ", @event.BooksOrdered.Select(x => x.Id).ToList()), ShippingCost = shippingCost, ShippingReference = $"SP{@event.Id}" }; _context.ShippingManifests.Add(shippingManifest); _context.SaveChanges(); _bus.Publish(new OrderShipped(Guid.NewGuid(), @event.CorrelationId, shippingManifest.ShippingReference, @event.BooksOrdered.Select(x => x.Id).ToList(), shippingCost, totalCostWithoutShipping + shippingCost)); }