Example #1
0
        //get order
        private void button6_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(textBox12.Text);

            CustomerOrder.Order o = Program.order.GetOrder(id);
            textBox1.Text += o.id + "\t" + o.data + "\t" + o.idC + "\t" + o.valoare + Environment.NewLine;
        }
Example #2
0
 //update order
 private void button8_Click(object sender, EventArgs e)
 {
     CustomerOrder.Order o = new CustomerOrder.Order();
     o.id      = Convert.ToInt32(textBox18.Text);
     o.data    = textBox17.Text;
     o.idC     = Convert.ToInt32(textBox19.Text);
     o.valoare = Convert.ToDecimal(textBox16.Text);
     Program.order.UpdateOrder(o);
 }
Example #3
0
 //detele order
 private void button9_Click(object sender, EventArgs e)
 {
     CustomerOrder.Order o = new CustomerOrder.Order();
     o.id      = Convert.ToInt32(textBox23.Text);
     o.data    = textBox22.Text;
     o.idC     = Convert.ToInt32(textBox20.Text);
     o.valoare = Convert.ToDecimal(textBox21.Text);
     Program.order.DeleteOrder(o);
 }
        private CustomerOrder.Order GenerateCustomerOrder(OrderModelDto model)
        {
            model.ClientInfo = _repositoryClient.GetClientById(model.ClientId ?? SettingsData.Constants.Entities.NULL_ID_INT);
            model.Phone      = _repositoryClient.GetPhoneById(model.PhoneId);
            var lstItem  = new List <Item>();
            var dictItem = new Dictionary <long, Item>();

            var hasPromo = model.PosOrder.Promos != null && model.PosOrder.Promos.Any();

            foreach (var item in model.PosOrder.LstItems)
            {
                if (hasPromo)
                {
                    if (model.PosOrder.Promos.ContainsKey(item.ItemId))
                    {
                        continue;
                    }
                }

                var itemToSend = new Item
                {
                    menuItemIdField  = item.ItemId.ToString(CultureInfo.InvariantCulture),
                    nameField        = item.Name,
                    referenceIdField = item.CheckItemId.ToString(CultureInfo.InvariantCulture),
                    quantityField    = SettingsData.Constants.StoreConst.QUANTITY_ITEM,
                    priceField       = item.Price.ToString(CultureInfo.InvariantCulture),
                    levelField       = item.Level.ToString(CultureInfo.InvariantCulture),
                    modCodeIdField   = item.ModCode.ToString(CultureInfo.InvariantCulture),
                    modGroupIdField  = item.Level > 0 ? item.Origin.ToString(CultureInfo.InvariantCulture) : null
                };

                dictItem[item.CheckItemId] = itemToSend;

                if (item.Parent == null)
                {
                    lstItem.Add(itemToSend);
                    continue;
                }

                var itemParent = dictItem[item.Parent.CheckItemId];

                if (itemParent.subItemsField == null)
                {
                    itemParent.subItemsField = new List <Item> {
                        itemToSend
                    };
                }
                else
                {
                    itemParent.subItemsField.Add(itemToSend);
                }
            }

            var order = new CustomerOrder.Order
            {
                customerField = new List <OrderCustomer>
                {
                    new OrderCustomer
                    {
                        firstNameField    = model.ClientInfo.FirstName.SubstringMax(27),
                        lastNameField     = model.ClientInfo.LastName.SubstringMax(27),
                        addressLine1Field = (model.AddressInfo.MainAddress + (String.IsNullOrWhiteSpace(model.AddressInfo.ExtIntNumber) ?
                                                                              String.Empty :
                                                                              String.Format("{0} ", model.AddressInfo.ExtIntNumber))).SubstringMax(44),
                        addressLine2Field = model.AddressInfo.RegionC.Value,
                        cityField         = model.AddressInfo.RegionB.Value,
                        stateField        = model.AddressInfo.RegionA.Value,
                        zipCodeField      = model.AddressInfo.ZipCode.Value,
                        emailAddressField = model.ClientInfo.Email,
                        phoneNumberField  = model.Phone,
                        notesField        = model.Message,
                        addressNotesField = model.AddressInfo.Reference
                    }
                },
                referenceIdField = model.OrderToStoreId.ToString(CultureInfo.InvariantCulture),
                modeField        = model.OrderDetails.PosOrderMode,//SettingsData.Constants.StoreConst.SENDING_MODE_DELIVERY,
                //statusField = "InDelay",
                itemsField = new List <OrderItems>
                {
                    new OrderItems
                    {
                        itemField = lstItem,
                    }
                }
            };

            if (hasPromo)
            {
                order.promosField = model.PosOrder.Promos.Values.Select(e =>
                {
                    var j = -1;
                    return(new OrderPromosPromo
                    {
                        promoTypeIdField = e.PromoTypeId.ToString(CultureInfo.InvariantCulture),
                        itemSelectionsField = e.LstEntries.Select(i =>
                        {
                            Item item;

                            if (dictItem.TryGetValue(i, out item))
                            {
                                item.priceField = null;
                            }

                            j++;
                            return new ItemSelection
                            {
                                groupIdField = j.ToString(CultureInfo.InvariantCulture),
                                itemReferenceIdField = i.ToString(CultureInfo.InvariantCulture)
                            };
                        }).ToList()
                    });
                }).ToList();
            }

            if (model.OrderDetails.PosOrderStatus == SettingsData.Constants.StoreConst.MODE_DELIVERY_FUTURE)
            {
                order.statusField      = SettingsData.Constants.TrackConst.IN_DELAY;
                order.promiseTimeField = model.OrderDetails.PromiseTime.ToString("o");
            }

            order.orderNotesField = String.Empty;
            if (String.IsNullOrWhiteSpace(model.OrderDetails.ExtraNotes) == false)
            {
                order.orderNotesField = model.OrderDetails.ExtraNotes;
            }

            order.orderNotesField = String.Format("{0} | Método de pago: {1} |", order.orderNotesField, model.OrderDetails.Payment.Name);
            return(order);
        }
        private static ResponseRd SendOrderToStore(OrderModelDto model, IHubCallerConnectionContext <dynamic> clients, CustomerOrder.Order order)
        {
            using (var client = new CustomerOrderClient(new BasicHttpBinding(), new EndpointAddress(model.Store.WsAddress + SettingsData.Constants.StoreOrder.WsCustomerOrder)))
            {
                var iTries = 0;
                while (iTries < 3)
                {
                    try
                    {
                        var result = client.AddOrder(order);
                        if (result.IsSuccess && result.Order.orderIdField.IsValidId())
                        {
                            clients.Caller.OnSendToStoreEventChange(new ResponseMessage
                            {
                                Code      = SettingsData.Constants.StoreConst.STORE_RESPONSE_CALL_WS_SUCCESS,
                                IsSuccess = true,
                                Message   = String.Format("Pedido (ATO ID {0}) enviado de forma exitosa", result.Order.orderIdField)
                            });
                            client.Close();
                            return(result);
                        }

                        var resultOrderId = result.IsSuccess ? result.Order.orderIdField : "ND";

                        SharedLogger.LogError(new Exception(
                                                  String.Format("SendOrderToStore: {0} | {1} | {2} | {3} | {4}", result.IsSuccess, result.ErrMsg, result.ResultCode, result.ResultData))
                                              , model.PosOrder, model.Store, model.Phone, model.OrderDetails, model.OrderToStoreId, resultOrderId);
                    }
                    catch (Exception ex)
                    {
                        SharedLogger.LogError(ex);
                        clients.Caller.OnSendToStoreEventChange(new ResponseMessage
                        {
                            Code      = SettingsData.Constants.StoreConst.STORE_RESPONSE_CALL_WS_ERROR,
                            IsSuccess = false,
                            Message   = String.Format("Intento {0} fallido. Error: {1}", (iTries + 1), ex.Message)
                        });
                    }
                    Thread.Sleep(1000);
                    iTries++;
                }

                client.Close();
            }

            return(null);
        }
 public void DeleteOrder(CustomerOrder.Order order)
 {
     base.Channel.DeleteOrder(order);
 }
 public void UpdateOrder(CustomerOrder.Order order)
 {
     base.Channel.UpdateOrder(order);
 }