Esempio n. 1
0
        //Get All Shopping Lists
        public static JavaList <ShoppingLists> GetShoppingLists()
        {
            var           lists    = new JavaList <ShoppingLists>();
            ShoppingLists allLists = null;

            lists.Clear();

            DBHelper dbh = new DBHelper();                      //db conn
            ICursor  c   = dbh.ReadAllShoppingLists();          //shopping lists

            while (c.MoveToNext())
            {
                string listId       = c.GetString(0);
                string title        = c.GetString(1);
                string listDesc     = c.GetString(2);
                string shoppingDate = c.GetString(3);
                string expBudget    = c.GetString(4);
                string actBudget    = c.GetString(5);
                string listStatus   = c.GetString(6);

                allLists                = new ShoppingLists();
                allLists.Id             = Convert.ToInt32(listId);
                allLists.ListTitle      = title;
                allLists.ListDesc       = listDesc;
                allLists.ShoppingDate   = shoppingDate;
                allLists.ExpectedBudget = Convert.ToDecimal(expBudget);
                allLists.ListStatus     = listStatus;
                lists.Add(allLists);
            }

            return(lists);
        }
Esempio n. 2
0
        public void AddEmptyShoppingList()
        {
            var sl = new ShoppingListModel();

            shoppingListsModel.AddShoppingList(sl);
            ShoppingLists.Add(new ShoppingListViewModel(sl));
        }
Esempio n. 3
0
        /// <summary>
        /// Replaces an old <c>Shop</c>-Object with a modified one.
        /// </summary>
        /// <param name="oldShop">The <c>Shop</c>-Object that should be replaced.</param>
        /// <param name="newShop">The <c>Shop</c>-Object that should be inserted into the Collection.</param>
        public void EditShop(Shop oldShop, Shop newShop)
        {
            // Get index of old object
            int idx = Shops.IndexOf(oldShop);

            // Clone ShoppingLists-List
            var templist = ShoppingLists.ToList();

            // Query all shopping lists and update the Shop object of the Shopping lists
            foreach (ShoppingList list in templist)
            {
                if (list.Shop.ID.Equals(oldShop.ID))
                {
                    // Get index of old object
                    int listIdx = ShoppingLists.IndexOf(list);

                    // Set new shop
                    list.Shop = newShop;

                    // Remove old object from list and insert new one
                    ShoppingLists.RemoveAt(listIdx);
                    ShoppingLists.Insert(listIdx, list);
                }
            }
            // Remove old object and insert new object at the same position as the old one
            Shops.Remove(oldShop);
            Shops.Insert(idx, newShop);

            // Save data to isolated storage
            SaveShops();
            SaveShoppingLists();

            // Replace old Geofence with new one
            ServiceLocator.Current.GetInstance <GeoHelper>().ModifyGeofence(oldShop.ID, newShop);
        }
Esempio n. 4
0
 /// <summary>
 /// Method to invoke when the Delete command is executed.
 /// </summary>
 /// <param name="parameter">The parameter of the command.</param>
 private async void OnDeleteExecute(object parameter)
 {
     if (await _messageService.Show("Are you sure that you want to remove the selected shopping list?", "Are you sure?", MessageButton.OKCancel) == MessageResult.OK)
     {
         ShoppingLists.Remove(SelectedShoppingList);
         SelectedShoppingList = null;
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Method to invoke when the Edit command is executed.
        /// </summary>
        /// <param name="parameter">The parameter of the command.</param>
        private void OnEditExecute(object parameter)
        {
            var parameters = new Dictionary <string, object>();

            parameters.Add("ShoppingListIndex", ShoppingLists.IndexOf(SelectedShoppingList));

            _navigationService.Navigate <ShoppingListViewModel>(parameters);
        }
Esempio n. 6
0
 private void LoadData()
 {
     ShoppingLists.Clear();
     shoppingListsModel.LoadShoppingLists();
     foreach (var slm in shoppingListsModel.ShoppingLists)
     {
         ShoppingLists.Add(new ShoppingListViewModel(slm));
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Called when the selected shopping list has changed.
        /// </summary>
        private void OnSelectedShoppingListChanged()
        {
            if (SelectedShoppingList != null)
            {
                var parameters = new Dictionary <string, object>();
                parameters.Add("ShoppingListIndex", ShoppingLists.IndexOf(SelectedShoppingList));

                _navigationService.Navigate <ShoppingListViewModel>(parameters);
            }
        }
Esempio n. 8
0
 private void DeleteSelectedList()
 {
     if (_selectedIndex > -1 && _selectedIndex < ShoppingLists.Count())
     {
         var toRemove = ShoppingLists.ElementAt(_selectedIndex);
         shoppingListsModel.RemoveShoppingList(toRemove.Id);
         ShoppingLists.RemoveAt(_selectedIndex);
         UpdataSavedData();
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Replaces an old <c>ShoppingList</c>-Object with a modified one.
        /// </summary>
        /// <param name="oldShoppingList">The <c>Shop</c>-Object that should be replaced.</param>
        /// <param name="newShoppingList">The <c>Shop</c>-Object that should be inserted into the Collection.</param>
        public void EditShoppingList(ShoppingList oldShoppingList, ShoppingList newShoppingList)
        {
            // Get index of old object
            int idx = ShoppingLists.IndexOf(oldShoppingList);

            // Remove old object and insert new object at the same position as the old one
            ShoppingLists.Remove(oldShoppingList);
            ShoppingLists.Insert(idx, newShoppingList);

            // Save data to isolated storage
            SaveShoppingLists();
        }
        public override Task Initialize()
        {
            ShoppingLists.Add(new ListItem
            {
                Title = "Test"
            });

            AddCmd = new MvxCommand(() =>
            {
                Debug.WriteLine("Click");
            });
            return(base.Initialize());
        }
 public void AddItem()
 {
     if (!string.IsNullOrWhiteSpace(_searchString) && _searchString.Length > 2)
     {
         var newList = new ShoppingList()
         {
             Name = _searchString
         };
         ShoppingLists.Insert(0, newList);
         Device.BeginInvokeOnMainThread(async() =>
         {
             Clear();
             _shoppingService.AddList(newList);
             await LoadData();
         });
     }
 }
Esempio n. 12
0
        //Check if a goal near deadline is available
        public static List <ShoppingLists> CheckItem(DateTime date)
        {
            var           list     = new List <ShoppingLists>();
            ShoppingLists allLists = null;

            list.Clear();

            DBHelper dbh = new DBHelper();                 //db conn
            ICursor  c   = dbh.ReadShoppingDeadline(date); //goal list

            while (c.MoveToNext())
            {
                string title = c.GetString(1);
                allLists           = new ShoppingLists();
                allLists.ListTitle = title;
                list.Add(allLists);
            }

            return(list);
        }
Esempio n. 13
0
        //Spinner List Items
        public static JavaList <ShoppingLists> SpinnerLists()
        {
            var           lists    = new JavaList <ShoppingLists>();
            ShoppingLists allLists = null;

            lists.Clear();

            DBHelper dbh = new DBHelper();                      //db conn
            ICursor  c   = dbh.ReadAllShoppingLists();          //shopping lists

            while (c.MoveToNext())
            {
                string listId = c.GetString(0);
                string title  = c.GetString(1);

                allLists           = new ShoppingLists();
                allLists.Id        = Convert.ToInt32(listId);
                allLists.ListTitle = title;
                lists.Add(title);
            }
            return(lists);
        }
Esempio n. 14
0
        /// <summary>
        /// Removes a <c>Shop</c>-Object from the <c>Shops</c>-Collection.
        /// </summary>
        /// <param name="shop">The <c>Shop</c>-Object that should be removed from the Collection.</param>
        public void DeleteShop(Shop shop)
        {
            Shops.Remove(shop);

            // Clone ShoppingLists-List
            var templist = ShoppingLists.ToList();

            // Query all shopping lists and update the Shop object of the Shopping lists
            foreach (ShoppingList list in templist)
            {
                if (list.Shop.ID.Equals(shop.ID))
                {
                    ShoppingLists.Remove(list);
                }
            }

            // Save data to isolated storage
            SaveShops();
            SaveShoppingLists();

            // Remove Geofence
            ServiceLocator.Current.GetInstance <GeoHelper>().RemoveGeofence(shop.ID);
        }
        private async Task ExecuteLoadShoppingListsCommand()
        {
            IsBusy = true;

            try
            {
                ShoppingLists.Clear();
                System.Collections.Generic.IEnumerable <ShoppingList> items = await ShoppingListDataStore.GetShoppingListsAsync();

                foreach (ShoppingList item in items)
                {
                    ShoppingLists.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 16
0
 public void RemoveShoppingList(int id)
 {
     ShoppingLists.RemoveAll(sl => sl.Id == id);
     //RemoveFromStorage(id);
 }
        public ShoppingListResult CreateShoppingList(AuthIdentity identity, ShoppingList list)
        {
            using (var session = this.GetSession())
            {
                var ret = new ShoppingListResult();

                using (var transaction = session.BeginTransaction())
                {
                    var shoppingList = new ShoppingLists();
                    shoppingList.Title = list.Title.Trim();
                    shoppingList.UserId = identity.UserId;
                    session.Save(shoppingList);

                    if (list.Any())
                    {
                        list.ToList().ForEach(i =>
                        {
                            var dbItem = ShoppingListItems.FromShoppingListItem(i);
                            dbItem.ShoppingList = shoppingList;
                            dbItem.UserId = shoppingList.UserId;
                            session.Save(dbItem);
                        });
                    }

                    transaction.Commit();

                    ret.NewShoppingListId = shoppingList.ShoppingListId;
                }

                ret.List = list;
                return ret;
            }
        }
Esempio n. 18
0
 /// <summary>
 /// Removes a <c>ShoppingList</c>-Object from the <c>ShoppingLists</c>-Collection.
 /// </summary>
 /// <param name="shoppingList">The <c>ShoppingList</c>-Object that should be removed from the Collection.</param>
 public void DeleteShoppingList(ShoppingList shoppingList)
 {
     ShoppingLists.Remove(shoppingList);
     SaveShoppingLists();
 }
Esempio n. 19
0
 /// <summary>
 /// Adds a new <c>ShoppingList</c>-Object to the <c>ShoppingLists</c>-Collection.
 /// </summary>
 /// <param name="shoppingList">The <c>ShoppingList</c>-Object that should added to the <c>ShoppingLists</c>-Collection.</param>
 public void AddShoppingList(ShoppingList shoppingList)
 {
     ShoppingLists.Add(shoppingList);
     SaveShoppingLists();
 }
Esempio n. 20
0
 public void AddShoppingList(ShoppingListModel shoppingListModel)
 {
     ShoppingLists.Add(shoppingListModel);
     //Save(shoppingListModel);
 }
Esempio n. 21
0
 public void LoadShoppingLists()
 {
     ShoppingLists.Clear();
     ShoppingLists = GetData(shoppingListsDAO, productsDAO);
 }
Esempio n. 22
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            if (inflater == null)
            {
                inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
            }

            if (convertView == null)
            {
                convertView = inflater.Inflate(Resource.Layout.ShoppingListItem, parent, false);
            }

            TextView myListId     = convertView.FindViewById <TextView>(Resource.Id.ListItemID);
            TextView myList       = convertView.FindViewById <TextView>(Resource.Id.ListItemName);
            TextView myShopDate   = convertView.FindViewById <TextView>(Resource.Id.ListItemDate);
            TextView myListBudget = convertView.FindViewById <TextView>(Resource.Id.ListItemBudget);
            TextView myListStatus = convertView.FindViewById <TextView>(Resource.Id.ListItemStatus);
            TextView myListNotify = convertView.FindViewById <TextView>(Resource.Id.ListItemNotification);

            list = lists[position];

            myListId.Text     = list.Id.ToString();
            myList.Text       = list.ListTitle;
            myShopDate.Text   = list.ShoppingDate;
            myListBudget.Text = list.ExpectedBudget.ToString();
            myListStatus.Text = list.ListStatus;

            int days = Convert.ToInt32(DateTime.Parse(list.ShoppingDate).Subtract(DateTime.Today).TotalDays);

            myListNotify.Text = days + " days left to shopping.";

            if (list.ListStatus.Equals("Pending"))
            {
                //item background
                convertView.SetBackgroundColor(Android.Graphics.Color.White);
                //list title color
                myList.SetTextColor(Android.Graphics.Color.SlateGray);
                //list status color
                myListNotify.SetTextColor(Android.Graphics.Color.White);
                //myListStatus.SetTextColor(Android.Graphics.Color.Rgb(183, 28, 28));
                //list notification visibility
                myListNotify.Visibility = ViewStates.Visible;

                if (days < 0)
                {
                    //myListStatus.SetBackgroundColor(Android.Graphics.Color.Rgb(236, 64, 122));
                    //myListNotify.SetBackgroundColor(Android.Graphics.Color.Rgb(183, 28, 28));

                    //item background
                    convertView.SetBackgroundColor(Android.Graphics.Color.Maroon);
                    //list title color
                    myList.SetTextColor(Android.Graphics.Color.White);
                    //list status color
                    myListStatus.SetTextColor(Android.Graphics.Color.White);
                    //list notification color
                    myListNotify.SetTextColor(Android.Graphics.Color.White);
                    //list notification text
                    myListNotify.Text = "Shopping is " + (days * -1) + " past due date. Do something!";
                }
                else if (days == 0)
                {
                    //convertView.SetBackgroundColor(Android.Graphics.Color.Rgb(240, 98, 146));

                    //list notification backgroundcolor
                    myListNotify.SetBackgroundColor(Android.Graphics.Color.Rgb(255, 82, 82));
                    //list notification text
                    myListNotify.Text = "Today is shopping day. Go shopping!";
                }
                else if (days > 0 && days <= 14)
                {
                    //convertView.SetBackgroundColor(Android.Graphics.Color.Rgb(244, 143, 177));

                    //list notification backgroundcolor
                    myListNotify.SetBackgroundColor(Android.Graphics.Color.Rgb(239, 154, 154));
                    //list notification text
                    myListNotify.Text = days + " days left to shopping.";
                }
                else if (days > 14)
                {
                    //list notification text
                    myListNotify.Text = days + " days left to shopping.";
                }
            }
            if (list.ListStatus.Equals("Postponed"))
            {
                convertView.SetBackgroundColor(Android.Graphics.Color.Rgb(130, 177, 255));
                //list title color
                myList.SetTextColor(Android.Graphics.Color.White);
                //list date visibility
                myShopDate.Visibility = ViewStates.Gone;
                //list notification visibility
                myListNotify.Visibility = ViewStates.Gone;
            }

            if (list.ListStatus.Equals("Completed"))
            {
                convertView.SetBackgroundColor(Android.Graphics.Color.Rgb(52, 148, 219));
                //list title color
                myList.SetTextColor(Android.Graphics.Color.White);
                //list status text
                myShopDate.Text = "Done on " + list.ShoppingDate;
                //list status color
                myListStatus.SetTextColor(Android.Graphics.Color.White);
                //list notification visibility
                myListNotify.Visibility = ViewStates.Gone;
            }

            return(convertView);
        }