Example #1
0
        /// <summary>
        ///     Executes the change check list command.
        /// </summary>
        /// <returns>The change check list command.</returns>
        private async Task ExecuteChangeCheckListCommand()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;
            ChangeCheckListCommand.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.DownloadChecklists();

                    if (res.IsSuccess)
                    {
                        if (!pendingCheckListToUpload)
                        {
                            object isMenu = false;
                            isBackNavigation = false;
                            await Page.NavigateToWithSelectedObject(PageEnum.MenuChecklist, true, isMenu);
                        }
                        else
                        {
                            IsBusy = false;
                            Page.DismissPopup();
                            await
                            Page.ShowAlert(string.Empty,
                                           HACCPUtil.GetResourceString(
                                               "CannotchangetheChecklistasrecordsarependingtobeuploadedTouploadtherecordsselectUploadRecordsundertheWirelessTasksmenu"));
                        }
                    }
                    else
                    {
                        IsBusy = false;
                        Page.DismissPopup();
                        await Page.ShowAlert(string.Empty, 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 check list. Exception: {0}", ex);
            }
            finally
            {
                IsBusy = false;
                Page.DismissPopup();
                ChangeCheckListCommand.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();
                }
            }
        }