コード例 #1
0
        /// <summary>
        /// Add the order, package up dictionary and send it to model layer
        /// </summary>
        /// <param name="items"></param>
        /// <param name="user"></param>
        /// <param name="amt"></param>
        /// <param name="shipDate"></param>
        /// <returns></returns>
        public void AddOrder(CartItem[] items, int cid, double amt)
        {
            Dictionary<string, Object> dictionaryReturnValues = new Dictionary<string, Object>();
            Dictionary<string, Object> dictionaryOrder = new Dictionary<string, Object>();

            try
            {
                Message = "";
                BackOrderFlag = 0;
                OrderID = -1;
                OrderModel myData = new OrderModel();
                int idx = 0;
                string[] prodcds = new string[items.Length];
                int[] qty = new int[items.Length];
                Decimal[] sellPrice = new Decimal[items.Length];

                foreach (CartItem item in items)
                {
                    prodcds[idx] = item.ProdCd;
                    sellPrice[idx] = item.Msrp;
                    qty[idx++] = item.Qty;
                }

                dictionaryOrder["prodcd"] = prodcds;
                dictionaryOrder["qty"] = qty;
                dictionaryOrder["msrp"] = sellPrice;
                dictionaryOrder["cid"] = cid;
                dictionaryOrder["amt"] = amt;
                dictionaryReturnValues = (Dictionary<string, Object>)Deserializer(myData.AddOrder(Serializer(dictionaryOrder)));
                OrderID = Convert.ToInt32(dictionaryReturnValues["orderid"]);
                BackOrderFlag = Convert.ToInt32(dictionaryReturnValues["boflag"]);
                Message = Convert.ToString(dictionaryReturnValues["message"]);
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "Order", "AddOrder");
                Message = ex.Message;
            }
        }
コード例 #2
0
        /// <summary>
        /// Get order information for a single customer
        /// </summary>
        /// <returns>List of OrderWeb instances to Presentation layer</returns>
        public List<OrderViewModel> GetAllForCust()
        {
            List<OrderViewModel> webOrders = new List<OrderViewModel>();
            try
            {
                OrderModel data = new OrderModel();
                List<Order> dataOrders = data.GetAllForCust(CustomerID);

                // We return OrderViewModel instances as the Asp layer has no knowledge of EF
                foreach (Order o in dataOrders)
                {
                    OrderViewModel ordWeb = new OrderViewModel();
                    ordWeb.OrderID = o.OrderID;
                    ordWeb.OrderDate = o.OrderDate;
                    ordWeb.OrderAmount = o.OrderAmount;
                    webOrders.Add(ordWeb);
                }
            }
            catch (Exception e)
            {
                ErrorRoutine(e, "OrderViewModel", "GetAllForCust");
            }
            return webOrders;
        }
コード例 #3
0
        /// <summary>
        /// Get order details for all orders for a customer
        /// </summary>
        /// <returns>List of OrderDetailWeb instances to Presentation layer</returns>
        public List<OrderDetailViewModel> GetAllDetailsForAllOrders()
        {
            List<OrderDetailViewModel> viewModelDetails = new List<OrderDetailViewModel>();

            try
            {
                OrderModel myData = new OrderModel();
                List<OrderDetailsModel> modelDetails = myData.GetAllDetailsForAllOrders(CustomerID);

                // this could be done with a foreach loop as well
                viewModelDetails = modelDetails.ConvertAll(new Converter<OrderDetailsModel,
                                                               OrderDetailViewModel>(ModelToViewModel));
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "OrderViewModel", "GetAllDetailsForAllOrders");
            }
            return viewModelDetails;
        }