Esempio n. 1
0
        public async void ExecuteMenuCommand(string index)
        {
            try
            {
                LoadingMessage = "Please Wait, for a moment...";
                IsLoading      = true;
                if (index == "1")
                {
                    CommonForMemoAndTransfer(1);
                }

                else if (index == "2")
                {
                    CommonForMemoAndTransfer(2);
                }

                else if (index == "3")
                {
                    CommonForMemoAndTransfer(3);
                }

                else if (index == "4")
                {
                    LoadingMessage = "Please Wait! Tables Loading...";
                    IsLoading      = true;
                    var functionResponse = await TableDataAccess.GetTableAsync();

                    if (functionResponse.status == "ok")
                    {
                        //var list = JsonConvert.DeserializeObject<List<TableDetail>>(functionResponse.result.ToString());
                        Helpers.Data.TableList = JsonConvert.DeserializeObject <List <TableDetail> >(functionResponse.result.ToString());
                    }
                    else
                    {
                        Helpers.Data.TableList = new List <TableDetail>();
                        IsLoading = false;
                        DependencyService.Get <IMessage>().ShortAlert(functionResponse.Message);
                        return;
                    }

                    LoadingMessage   = "Please Wait! Order Items  Loading...";
                    IsLoading        = true;
                    functionResponse = await TableDataAccess.GetAllKOTProdAsync(Helpers.Constants.User.UserName);

                    if (functionResponse.status == "ok")
                    {
                        IsLoading = false;
                        DependencyService.Get <IMessage>().ShortAlert("Order Items loaded successfully");
                        Helpers.Data.OrderItemsList = JsonConvert.DeserializeObject <List <KOTAppClassLibrary.Models.KOTProd> >(functionResponse.result.ToString());
                        await App.Current.MainPage.Navigation.PushAsync(new KitchenDispatchPage());
                    }
                    else
                    {
                        DependencyService.Get <IMessage>().ShortAlert("Couldnot Load: " + functionResponse.Message);
                    }
                    IsLoading = false;
                }

                else if (index == "5")
                {
                    var res = await App.Current.MainPage.DisplayAlert("Confirm", "Are you sure to Sync MenuItems?", "Yes", "No");

                    if (res)
                    {
                        LoadingMessage = "Please Wait, MenuItems Loading";
                        IsLoading      = true;
                        var functionResponse = await LoadMenuItem.GetMenuItemAsync();

                        if (functionResponse.status == "ok")
                        {
                            DependencyService.Get <IMessage>().ShortAlert("MenuItems synced successfully");
                            MenuItemsList = JsonConvert.DeserializeObject <List <KOTAppClassLibrary.Models.MenuItem> >(functionResponse.result.ToString());
                            Helpers.Data.MenuItemsList = MenuItemsList;
                            MenuItemsAccess.SaveList(App.DatabaseLocation, MenuItemsList);
                        }
                        else
                        {
                            DependencyService.Get <IMessage>().ShortAlert("Couldnot sync: " + functionResponse.Message);
                        }
                    }
                    IsLoading = false;
                }

                else if (index == "6")
                {
                    var res = await App.Current.MainPage.DisplayAlert("Confirm", "Are you sure to log Out?", "Yes", "No");

                    if (res)
                    {
                        LoginUser.DeleteUserAndIP(App.DatabaseLocation);
                        App.Current.MainPage = new LoginPage();
                    }
                }
            }catch (Exception e)
            {
                IsLoading = false;
                DependencyService.Get <IMessage>().ShortAlert("Error: " + e.Message);
            }
        }