//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); }
public void AddEmptyShoppingList() { var sl = new ShoppingListModel(); shoppingListsModel.AddShoppingList(sl); ShoppingLists.Add(new ShoppingListViewModel(sl)); }
/// <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); }
/// <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; } }
/// <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); }
private void LoadData() { ShoppingLists.Clear(); shoppingListsModel.LoadShoppingLists(); foreach (var slm in shoppingListsModel.ShoppingLists) { ShoppingLists.Add(new ShoppingListViewModel(slm)); } }
/// <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); } }
private void DeleteSelectedList() { if (_selectedIndex > -1 && _selectedIndex < ShoppingLists.Count()) { var toRemove = ShoppingLists.ElementAt(_selectedIndex); shoppingListsModel.RemoveShoppingList(toRemove.Id); ShoppingLists.RemoveAt(_selectedIndex); UpdataSavedData(); } }
/// <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(); }); } }
//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); }
//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); }
/// <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; } }
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; } }
/// <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(); }
/// <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(); }
public void AddShoppingList(ShoppingListModel shoppingListModel) { ShoppingLists.Add(shoppingListModel); //Save(shoppingListModel); }
public void LoadShoppingLists() { ShoppingLists.Clear(); ShoppingLists = GetData(shoppingListsDAO, productsDAO); }
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); }