Example #1
0
        /// <summary>
        ///     Executes the change menu command.
        /// </summary>
        /// <returns>The change menu command.</returns>
        private async Task ExecuteChangeMenuCommand()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;
            ChangeMenuCommand.ChangeCanExecute();
            Page.ShowProgressIndicator();

            try
            {
                if (haccpService.IsConnected() == false)
                {
                    IsBusy = false;
                    Page.DismissPopup();

                    Page.DisplayAlertMessage(HACCPUtil.GetResourceString("EnableNetworkConnection"),
                                             HACCPUtil.GetResourceString(
                                                 "YourequireanactiveInternetconnectiontoperformsomefunctionsWerecommendthatyouenableWiFiforthispurposeDatachargesmayapplyifWiFiisnotenabled"));

                    return;
                }

                if (HaccpAppSettings.SharedInstance.SiteSettings.SiteId > 0)
                {
                    var res = await haccpService.DownloadMenus();

                    if (res.IsSuccess)
                    {
                        var menuLists = (IList <Menu>)res.Results;
                        if (menuLists.Count > 0)
                        {
                            if (!pendingTemperatureRecordsToUpload)
                            {
                                object isMenu = true;
                                isBackNavigation = false;
                                await Page.NavigateToWithSelectedObject(PageEnum.MenuChecklist, true, isMenu);
                            }
                            else
                            {
                                IsBusy = false;
                                Page.DismissPopup();
                                await
                                Page.ShowAlert(string.Empty,
                                               HACCPUtil.GetResourceString(
                                                   "CannotchangetheMenuasrecordsarependingtobeuploadedTouploadtherecordsselectUploadRecordsundertheWirelessTasksmenu"));
                            }
                        }
                    }
                    else
                    {
                        IsBusy = false;
                        Page.DismissPopup();
                        await Page.ShowAlert("", res.Message);
                    }
                }
                else
                {
                    IsBusy = false;
                    Page.DismissPopup();
                    await
                    Page.ShowAlert(HACCPUtil.GetResourceString("NoSiteInformationFound"),
                                   HACCPUtil.GetResourceString(
                                       "NositeinformationsfoundPleasetapUpdateSiteandSettingsintheWirelessTasksmenu"));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Ooops! Something went wrong while select menu. Exception: {0}", ex);
            }
            finally
            {
                IsBusy = false;
                Page.DismissPopup();
                ChangeMenuCommand.ChangeCanExecute();
            }
        }
        /// <summary>
        /// LoadMenuChecklists
        /// </summary>
        /// <returns></returns>
        public async Task LoadMenuChecklists()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;
            Page.ShowProgressIndicator();
            if (IsMenu)
            {
                try
                {
                    var res = await haccpService.DownloadMenus();

                    if (res.IsSuccess)
                    {
                        var menuLists = (IList <Menu>)res.Results;
                        if (menuLists.Any())
                        {
                            Menus = new ObservableCollection <Menu>(menuLists);
                        }
                        else
                        {
                            IsBusy = false;
                            Page.DismissPopup();
                            await
                            Page.ShowAlert(HACCPUtil.GetResourceString("NoMenusFound"),
                                           HACCPUtil.GetResourceString("Nomenusfoundintheserver"));
                        }
                    }
                    else
                    {
                        IsBusy = false;
                        Page.DismissPopup();
                        Page.DisplayAlertMessage("", res.Message);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Ooops! Something went wrong while fetch menu list  from server. Exception: {0}", ex);
                }
                finally
                {
                    IsBusy = false;
                    Page.DismissPopup();
                }
            }
            else
            {
                try
                {
                    var res = await haccpService.DownloadChecklists();

                    if (res.IsSuccess)
                    {
                        var _checklists = (IList <Checklist>)res.Results;
                        if (_checklists.Any())
                        {
                            Checklists = new ObservableCollection <Checklist>(_checklists);
                        }
                        else
                        {
                            IsBusy = false;
                            Page.DismissPopup();
                            await
                            Page.ShowAlert(HACCPUtil.GetResourceString("NoChecklistsFound"),
                                           HACCPUtil.GetResourceString("Nochecklistsfoundintheserver"));
                        }
                    }
                    else
                    {
                        IsBusy = false;
                        Page.DismissPopup();
                        Page.DisplayAlertMessage("", res.Message);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Ooops! Something went wrong while fetch checklist from server. Exception: {0}", ex);
                }
                finally
                {
                    IsBusy = false;
                    Page.DismissPopup();
                }
            }
        }