public void SetUp()
        {
            //create a customer, and fetch it, so we can add an order to it
            String cust1String = Guid.NewGuid().ToString();

            Int32 customerId = DataService.AddCustomer(
                GetCustomer(cust1String, "1"));

            if (customerId > 0)
                cust = DataAccess.DataService.
                    FetchAllCustomers().Where(c => c.CustomerId == customerId).Single();


            //create a Order against the customer we just created

            DataService.AddOrder(GetOrder(customerId));
            DataService.AddOrder(GetOrder(customerId));
            DataService.AddOrder(GetOrder(customerId));
            DataService.AddOrder(GetOrder(customerId));
            Int32 orderId = DataService.AddOrder(
                GetOrder(customerId));


            if (orderId > 0)
                ord = DataAccess.DataService.
                    FetchAllOrders(customerId).Where(o => o.OrderId == orderId).Single();
        }
Beispiel #2
0
        /// <summary>
        /// Allows Service layer objects to be translated into
        /// UI objects
        /// </summary>
        /// <param name="cust">Service layer object</param>
        /// <returns>UI layer object</returns>
        public static OrderModel OrderToOrderModel(Order order)
        {
            OrderModel orderModel = new OrderModel();
            orderModel.OrderId.DataValue = order.OrderId;
            orderModel.CustomerId.DataValue = order.CustomerId;
            orderModel.Quantity.DataValue = order.Quantity;
            orderModel.ProductId.DataValue = order.ProductId;
            orderModel.DeliveryDate.DataValue = order.DeliveryDate;
            return orderModel;

        }
 /// <summary>
 /// Translates a UI OrderModel into a data layer Order
 /// </summary>
 /// <param name="uiLayerOrder">A UI OrderModel</param>
 /// <returns>A data layer Order</returns>
 private Order TranslateUIOrderToDataLayerOrder(OrderModel uiLayerOrder)
 {
     Order dataLayerOrder = new Order();
     dataLayerOrder.OrderId = uiLayerOrder.OrderId.DataValue;
     dataLayerOrder.CustomerId = CurrentCustomer.CustomerId.DataValue;
     dataLayerOrder.ProductId = CurrentProduct.ProductId;
     dataLayerOrder.Quantity = uiLayerOrder.Quantity.DataValue;
     dataLayerOrder.DeliveryDate = uiLayerOrder.DeliveryDate.DataValue;
     return dataLayerOrder;
 }
 /// <summary>
 /// Creates a dummy Order to insert into the database
 /// </summary>
 private Order GetOrder(Int32 customerId)
 {
     Order o = new Order();
     o.CustomerId = customerId;
     o.Quantity=2;
     o.ProductId =1;
     o.DeliveryDate = DateTime.Now;
     return o;
 }
Beispiel #5
0
		private void attach_Orders(Order entity)
		{
			this.SendPropertyChanging();
			entity.Product = this;
		}
Beispiel #6
0
		private void detach_Orders(Order entity)
		{
			this.SendPropertyChanging();
			entity.Product = null;
		}
Beispiel #7
0
 partial void DeleteOrder(Order instance);
Beispiel #8
0
 partial void UpdateOrder(Order instance);
Beispiel #9
0
 partial void InsertOrder(Order instance);
Beispiel #10
0
		private void detach_Orders(Order entity)
		{
			this.SendPropertyChanging();
			entity.Customer = null;
		}
Beispiel #11
0
		private void attach_Orders(Order entity)
		{
			this.SendPropertyChanging();
			entity.Customer = this;
		}