public GetLicenceViewModel()
        {
            GetLicenseCommand = new Command <string>(async(arg) =>
            {
                TokenExpManger tokenExpManger = new TokenExpManger(App.TokenDto.Exp);
                if (tokenExpManger.IsExpired())
                {
                    await tokenExpManger.CloseSession();
                }
                else
                {
                    var result = await Shell.Current.DisplayAlert("Notification", "Your are going to get a store license.For the cost $100 by month. Are you OK with that?", "Yes", "No");

                    if (result)
                    {
                        var cardResult = await CardDataStore.GetCardFromUser(App.LogUser.UserId, App.TokenDto.Token);

                        if (cardResult != null && cardResult.Count() > 0)
                        {
                            //Make the Payment transation here...

                            //Check that the payment was submited.

                            //Send Lincese Code

                            var subcriptionToken = await stripeServiceDS.CreateACustomerSubcription(App.LogUser.StripeUserId);

                            if (!string.IsNullOrEmpty(subcriptionToken))
                            {
                                var subcription = new Library.Models.Subcription()
                                {
                                    StripeCustomerId    = App.LogUser.StripeUserId,
                                    StripeSubCriptionID = subcriptionToken,
                                    //StoreLicense = StoreControlPanelViewModel.YourSelectedStore.StoreLicenceId
                                };

                                var subcriptionResult = await SubcriptionDataStore.AddItemAsync(subcription);

                                if (subcriptionResult)
                                {
                                    var licenseReuslt = await storeLicenseDataStore.PostStoreLicense(App.LogUser.Email, App.LogUser.Name);

                                    if (licenseReuslt)
                                    {
                                        await App.Current.MainPage.DisplayAlert("Notification", "License added succefully.", "OK");
                                    }
                                }
                            }
                            else
                            {
                                await App.Current.MainPage.DisplayAlert("Notification", "The subcription could not be made. Try again.", "OK");
                            }
                        }
                        else
                        {
                            await App.Current.MainPage.DisplayAlert("Notification", "You dont have a card register, register a card first.", "OK");
                        }
                    }
                }
            });
        }
        public UserDetailOrderViewModel()
        {
            ProductPresenters = new ObservableCollection <ProductPresenter>();

            OrderDetail        = SelectedOrder.CurrentOrder;
            OrderStatus        = OrderDetail.OrderStatus.ToString();
            OrderQuantity      = OrderDetail.OrderProducts.Count();
            isDeliveryFeeAdded = false;

            if (OrderDetail.OrderStatus == Status.Submited || OrderDetail.OrderStatus == Status.Completed)
            {
                AreVisible = false;
            }
            else
            {
                AreVisible = true;
            }

            SetProducts();

            IspickUp        = true;
            CheckoutCommand = new Command(async() =>
            {
                TokenExpManger tokenExpManger = new TokenExpManger(App.TokenDto.Exp);

                if (tokenExpManger.IsExpired())
                {
                    await tokenExpManger.CloseSession();
                }
                else
                {
                    var cardofUser = await CardDataStore.GetCardFromUser(App.LogUser.UserId, App.TokenDto.Token);

                    App.LogUser.PaymentCards = new List <PaymentCard>(cardofUser);

                    if (App.LogUser.PaymentCards.Count() > 0)
                    {
                        if (OrderDetail.OrderStatus == Status.NotSubmited)
                        {
                            if (IsDelivery)
                            {
                                OrderDetail.OrderType = Library.Models.Type.Delivery;
                            }
                            if (IspickUp)
                            {
                                OrderDetail.OrderType = Library.Models.Type.PickUp;
                            }

                            if (!IsDelivery && !IspickUp)
                            {
                                OrderDetail.OrderType = Library.Models.Type.PickUp;
                            }

                            OrderDetail.OrderStatus = Status.Submited;

                            //List<PaymentCard> paymentCards = new List<PaymentCard>(App.LogUser.PaymentCards);

                            var customercardId = await stripeServiceDS.GetCustomerCardId(App.LogUser.StripeUserId, App.LogUser.PaymentCards.FirstOrDefault().StripeCardId);

                            var isTransactionSuccess = await stripeServiceDS.MakePaymentWithCard(OrderDetail.StoreId, Total, App.LogUser.PaymentCards.FirstOrDefault().PaymentCardId, OrderDetail.OrderId.ToString());

                            if (isTransactionSuccess)
                            {
                                var orderUpdate = await orderDataStore.UpdateItemAsync(OrderDetail);

                                OrderStatus = OrderDetail.OrderStatus.ToString();

                                if (orderUpdate)
                                {
                                    var orderNotificationToEmployees = await userConnectedDataStore.SendOrdersToEmployees(OrderDetail.StoreId.ToString(), OrderDetail.OrderId.ToString());

                                    //await App.ComunicationService.OrderToPrepare(OrderDetail);

                                    await App.Current.MainPage.DisplayAlert("Notification", "Order was submited...!", "OK");

                                    MessagingCenter.Send <Library.Models.Order>(OrderDetail, "RemoveOrderSubtmitedMsg");
                                }
                            }
                            else
                            {
                                await App.Current.MainPage.DisplayAlert("Notification", "Bad Transaction.", "OK");
                            }
                        }
                        else
                        {
                            await App.Current.MainPage.DisplayAlert("Notification", "Order was submited.", "OK");
                        }
                    }
                    else
                    {
                        await App.Current.MainPage.DisplayAlert("Notification", "You dont have a card register, register a card first.", "OK");
                    }
                }
            });

            CalculateTotal();

            MessagingCenter.Subscribe <ProductPresenter>(this, "RemoveOrderProduct", async(obj) =>
            {
                ProductPresenters.Remove(obj);

                var _orderProductToRemove = OrderDetail.OrderProducts.Where(o => o.OrderProductId == obj.ProductId).FirstOrDefault();

                OrderDetail.OrderProducts.Remove(_orderProductToRemove);

                OrderQuantity = OrderDetail.OrderProducts.Count();

                if (OrderDetail.OrderProducts.Count() == 0)
                {
                    var result = await orderDataStore.DeleteItemAsync(OrderDetail.OrderId.ToString());

                    if (result)
                    {
                        await Shell.Current.GoToAsync($"../StoreOrderRoute");
                    }
                }
                CalculateTotal();
            });
            MessagingCenter.Subscribe <OrderProduct>(this, "OrderProductUpdate", async(obj) =>
            {
                var oproductToRemove = ProductPresenters.Where(op => op.ProductId == obj.OrderProductId).FirstOrDefault();

                ProductPresenters.Remove(oproductToRemove);

                var updatedOrderProductPrensenter = new ProductPresenter(obj);

                if (OrderDetail.OrderStatus == Status.Submited || OrderDetail.OrderStatus == Status.Completed)
                {
                    updatedOrderProductPrensenter.AreVisible = false;
                }
                else
                {
                    updatedOrderProductPrensenter.AreVisible = true;
                }
                ProductPresenters.Add(updatedOrderProductPrensenter);

                CalculateTotal();
            });
        }