Ejemplo n.º 1
0
        public bool CreateOrderFromXML(Order XMLOrder, string Time, string Location)
        {
            int OrderNum = XMLOrder.OrderNum;

            // transfer order
            DeliverySupport.Models.IOrderModel order = dataFactory.MakeOrderFrmXMLOrder(XMLOrder);
            if (Time.Length > 0)
            {
                order.TimeCreated = DateTime.Parse(Time);
            }
            order.LocationCreated = Location;
            order.IsTestObject    = IsTestObject;

            // transfer Customer

            List <DeliverySupport.Models.IOrderCustomerModel> customers = new List <DeliverySupport.Models.IOrderCustomerModel>();

            if (XMLOrder.CustomerObj != null)
            {
                DeliverySupport.Models.IOrderCustomerModel customer = dataFactory.MakeOrderCustomerFromXMLCustomer(XMLOrder.CustomerObj);
                customer.OrderNum = OrderNum;
                customers.Add(customer);
            }
            order.Customers = customers;

            // transfer item(s)
            List <DeliverySupport.Models.IOrderItemModel> items = new List <DeliverySupport.Models.IOrderItemModel>();

            foreach (Models.Item xmlItem in XMLOrder.Items)
            {
                DeliverySupport.Models.IOrderItemModel item = dataFactory.MakeOrderItemFromXMLItem(xmlItem);
                item.OrderNum = OrderNum;
                items.Add(item);
            }
            order.OrderItems = items;


            // need to find a better way of doing this
            Task.Run(async() =>
            {
                await _orderDataService.Create(order);
            }).Wait();

            return(true);
        }