Esempio n. 1
0
        public string SyncOrderItems()
        {
            string errorMessage = string.Empty;

            try
            {
                List <TOrderItem> torderitem = ServerConnector.GetInstance().SyncOrderItemRequest();

                using (OrderItemBusiness business = new OrderItemBusiness())
                {
                    foreach (var item in torderitem)
                    {
                        business.DeleteByOrderId(item.OrderId);
                    }
                }

                //TOrderItem
                AppLogger.logInfo("SyncOrderItems", "[TOrderItem]");
                errorMessage = SyncObject <TOrderItem, OrderItem>(torderitem);
            }
            catch (Exception exc)
            {
                AppLogger.logError("SyncOrderItems", exc);
                return(exc.Message);
            }
            return(errorMessage);
        }
        public string UpdateOrderInfo(TOrder torder, List <TOrderItem> orderItems, string userId)
        {
            try
            {
                //Check Order
                string errorMessage = CheckOrder(torder, true);

                //check OrderItem
                errorMessage += orderItems.Count == 0 ? "Không có thông tin hàng hóa" : "";

                if (string.IsNullOrEmpty(errorMessage) == false)
                {
                    return(errorMessage);
                }

                if (torder.Type == Constants.VALUE_ORDER_TYPE_REGULAR)
                {
                    using (RegularOrderBusiness business = new RegularOrderBusiness())
                    {
                        business.Update(ThriftUtil.ConvertToEntityObject(torder) as RegularOrder);
                    }
                }
                else
                {
                    using (IrregularOrderBusiness business = new IrregularOrderBusiness())
                    {
                        business.Update(ThriftUtil.ConvertToEntityObject(torder) as IrregularOrder);
                    }
                }

                using (OrderItemBusiness business = new OrderItemBusiness())
                {
                    business.DeleteByOrderId(torder.OrderId);

                    business.Insert(ThriftUtil.ConvertToOrderItemList(orderItems).Cast <OrderItem>());
                }

                //notify to the others client station
                //BroadcastToClient(ClientAction.UpdateOrder,order,orderItems);

                return("");
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[UpdateOrderInfo]", exc);
                return(exc.Message);
            }
        }
        /// <summary>
        /// CompleteOrder (just using for Irregular Order)
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public string DeleteOrder(TOrder order, string userId)
        {
            try
            {
                // Check Order
                string errorMessage = CheckOrder(order, true);

                if (string.IsNullOrEmpty(errorMessage) == false)
                {
                    return(errorMessage);
                }

                // Delete
                if (order.Type == Constants.VALUE_ORDER_TYPE_REGULAR)
                {
                    RegularOrderBusiness business = new RegularOrderBusiness();
                    business.Delete(order.OrderId);
                }
                else
                {
                    IrregularOrderBusiness business = new IrregularOrderBusiness();
                    business.Delete(order.OrderId);
                }

                OrderItemBusiness itemBusiness = new OrderItemBusiness();
                itemBusiness.DeleteByOrderId(order.OrderId);

                ////notify to the others client station
                ////BroadcastToClient(ClientAction.CompleteOrder,order);

                return("");
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[DeleteOrder]", exc);
                return(exc.Message);
            }
        }