public async Task AddCategory(string category)
        {
            if (IsBusy || string.IsNullOrEmpty(category))
            {
                return;
            }

            IsBusy = true;

            var itemCategory = new Category()
            {
                DisplayName = category
            };

            if (!MenuItems.Contains(itemCategory))
            {
                MenuItems.Add(itemCategory);
                await _cache.InsertLocalObject(CacheKeyDictionary.CategoryItems, MenuItems);
            }
            else
            {
                await _dialogService.DisplayAlertAsync("", "Esta categoria ya esta registrada! :(", "Ok");
            }

            IsBusy = false;
        }
示例#2
0
        private async void Init()
        {
            var categories = await _cache.GetLocalObject <ObservableCollection <Category> >(CacheKeyDictionary.CategoryItems);

            if (categories?.Count > 0)
            {
                Categories = new ObservableCollection <Category>(categories);
            }
            else
            {
                Categories = new ObservableCollection <Category>
                {
                    new Category()
                    {
                        DisplayName = "Privado"
                    },
                    new Category()
                    {
                        DisplayName = "Familia"
                    },
                    new Category()
                    {
                        DisplayName = "Trabajo"
                    }
                };
                await _cache.InsertLocalObject(CacheKeyDictionary.CategoryItems, Categories);
            }
        }
        public async void SetNotificatonShowed()
        {
            if (_items == null || _items.Count == 0)
            {
                return;
            }

            foreach (var item in _items)
            {
                if (item.Date.Date <= DateTime.Today)
                {
                    item.Showed = true;
                }
            }

            await _cache.InsertLocalObject(CacheKeyDictionary.ItemList, _items);
        }
        private async void ShowNotifications()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            var navParameters = new NavigationParameters {
                { "itemColletion", Items }
            };
            await _navigationService.NavigateAsync("NotificationPage", navParameters);

            await CrossNotifications.Current.CancelAll();

            await CrossNotifications.Current.SetBadge(0);

            IconNotification = "ic_notification.png";
            await _cache.InsertLocalObject(CacheKeyDictionary.LastCheck, DateTime.Now);

            IsBusy = false;
        }