Пример #1
0
        private async void LoginButtonClicked()
        {
            if (Regex.IsMatch(UserName, "[^A-Za-z0-9]+"))
            {
                IsErrorShown = true;
                ErrorMessage = "Invalid User Name Only Chars and numbers are allowed";
            }
            else
            {
                IsLoading    = true;
                IsErrorShown = false;
                ErrorMessage = "";
                var UserTable = Client.GetTableReference <User>();
                var user      = await UserService.PostUserAsync(new User()
                {
                    Name = UserName
                });

                var UsersTable = OfflineManager.GetOfflineSyncTableReference <User>();
                var Users      = await OfflineManager.GetAllOfflineSyncItemsAsync <User>(UsersTable);

                if (!Users.Any(i => i.ID == SharedUser?.ID))
                {
                    await OfflineManager.InsertOfflineSyncObjectAsync <User>(new User()
                    {
                        Name = SharedUser?.Name, ID = SharedUser?.ID
                    }, UsersTable);
                }


                Application.Current.Properties["UserName"] = UserName;
                Application.Current.Properties["User"]     = user != null ? user : new User()
                {
                    Name = UserName
                };
                await NavigationHelper.NavigateToPageAsync(new HomePage());

                UserName  = null;
                IsLoading = false;
            }
        }
Пример #2
0
        public async Task GetAllItemsFromLocalDBAsync()
        {
            try
            {
                IsLoading = true;
                var Table  = OfflineManager.GetOfflineSyncTableReference <Item>();
                var result = await OfflineManager.GetAllOfflineSyncItemsAsync <Item>(Table);

                for (int i = 0; i < result?.Count; i++)
                {
                    result[i].SmallDetails = result[i].Details.Length > 51 ? result[i].Details.Substring(0, 50) : result[i].Details;
                }
                Filter(result);
                IsLoading = false;
            }
            catch (Exception ex)
            {
                IsLoading = false;
                await PopUpsHelper.DisplayMessage("Sync Error", "Error While Getting all offline products", "OK");
            }
        }