public Task <int> PutItemAsync(FavoriteLocation loc) { if (loc.ID != 0) { return(Database.UpdateAsync(loc)); } return(null); }
public void Add(IBotData botData, FavoriteLocation value) { var favorites = this.GetFavorites(botData); if (favorites.Count >= MaxFavoriteCount) { throw new InvalidOperationException("The max allowed number of favorite locations has already been reached."); } favorites.Add(value); botData.UserData.SetValue(FavoritesKey, favorites); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { tableView.DeselectRow(indexPath, true); if (FavoriteSelected != null) { int index = indexPath.Row; FavoriteLocation fav = mFavorites [index]; FavoriteSelected(fav.Location); } }
public async Task Add(ITurnContext context, FavoriteLocation value) { var favorites = await GetFavorites(context); if (favorites.Count >= MaxFavoriteCount) { throw new InvalidOperationException("The max allowed number of favorite locations has already been reached."); } favorites.Add(value); await _favoriteLocations.SetAsync(context, favorites); }
public int SaveFavoriteLocation(FavoriteLocation item) { lock (locker) { if (item.Id != 0) { Update(item); return(item.Id); } else { return(Insert(item)); } } }
partial void StarStartClicked(MonoTouch.Foundation.NSObject sender) { AppDelegate appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate; FavoritesDbManager favorites = appDelegate.FavoriteLocations; FavoriteLocation fav = new FavoriteLocation(); fav.Location = txtStartLocation.Text; favorites.SaveFavoriteLocation(fav); UIAlertView alert = new UIAlertView("Saved", "Location saved to favorites.", null, "OK", null); alert.Show(); }
public void Delete(IBotData botData, FavoriteLocation value) { var favorites = this.GetFavorites(botData); var newFavorites = new List <FavoriteLocation>(); foreach (var favoriteItem in favorites) { if (!AreEqual(favoriteItem.Location, value.Location)) { newFavorites.Add(favoriteItem); } } botData.UserData.SetValue(FavoritesKey, newFavorites); }
public async Task Add(ITurnContext context, FavoriteLocation value) { var favorites = await GetFavorites(context); if (favorites.Count >= MaxFavoriteCount) { throw new InvalidOperationException("The max allowed number of favorite locations has already been reached."); } favorites.Add(value); var state = context.GetConversationState <Dictionary <string, object> >(); state[FavoritesKey] = favorites; }
public void OnSaveFavorite(String favoriteLocation) { FavoriteLocation favLoc = new FavoriteLocation(); favLoc.Location = favoriteLocation; FavoritesRepository.SaveFavoriteLocation(favLoc); var builder = new AlertDialog.Builder(activity); builder.SetTitle("Favorites"); builder.SetMessage("Saved to favorites"); builder.SetNegativeButton("OK", (object sender, DialogClickEventArgs e) => { (sender as Dialog).Cancel(); }); builder.Create().Show(); }
public async Task Delete(ITurnContext context, FavoriteLocation value) { var favorites = await GetFavorites(context); var newFavorites = new List <FavoriteLocation>(); foreach (var favoriteItem in favorites) { if (!AreEqual(favoriteItem.Location, value.Location)) { newFavorites.Add(favoriteItem); } } await _favoriteLocations.SetAsync(context, newFavorites); }
public FavoriteLocation AddToFavorites(Location location) { if (location != null) { var locationModel = new FavoriteLocation() { Key = location.Key, LocalizedName = location.LocalizedName }; _dbContext.FavoriteLocations.Add(locationModel); if (_dbContext.SaveChanges() > 0) { return(locationModel); } } return(null); }
public async Task Delete(ITurnContext context, FavoriteLocation value) { var favorites = await GetFavorites(context); var newFavorites = new List <FavoriteLocation>(); foreach (var favoriteItem in favorites) { if (!AreEqual(favoriteItem.Location, value.Location)) { newFavorites.Add(favoriteItem); } } var state = context.GetConversationState <Dictionary <string, object> >(); state[FavoritesKey] = newFavorites; }
/*public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath) * { * return 33; * }*/ public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = tableView.DequeueReusableCell(mCellIdentifier); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, mCellIdentifier); } int index = indexPath.Row; FavoriteLocation fav = mFavorites [index]; cell.TextLabel.Text = fav.Location; return(cell); }
public void Update(IBotData botData, FavoriteLocation currentValue, FavoriteLocation newValue) { var favorites = this.GetFavorites(botData); var newFavorites = new List <FavoriteLocation>(); foreach (var item in favorites) { if (AreEqual(item.Location, currentValue.Location)) { newFavorites.Add(newValue); } else { newFavorites.Add(item); } } botData.UserData.SetValue(FavoritesKey, newFavorites); }
public async Task Update(ITurnContext context, FavoriteLocation currentValue, FavoriteLocation newValue) { var favorites = await GetFavorites(context); var newFavorites = new List <FavoriteLocation>(); foreach (var item in favorites) { if (AreEqual(item.Location, currentValue.Location)) { newFavorites.Add(newValue); } else { newFavorites.Add(item); } } await _favoriteLocations.SetAsync(context, newFavorites); }
public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, MonoTouch.Foundation.NSIndexPath indexPath) { AppDelegate appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate; FavoritesDbManager favorites = appDelegate.FavoriteLocations; switch (editingStyle) { case UITableViewCellEditingStyle.Delete: // remove the item from the underlying data source FavoriteLocation fav = mFavorites [indexPath.Row]; favorites.DeleteFavoriteLocation(fav); // delete the row from the table mFavorites.RemoveAt(indexPath.Row); tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade); break; case UITableViewCellEditingStyle.None: Console.WriteLine("CommitEditingStyle:None called"); break; } }
public async Task Update(ITurnContext context, FavoriteLocation currentValue, FavoriteLocation newValue) { var favorites = await GetFavorites(context); var newFavorites = new List <FavoriteLocation>(); foreach (var item in favorites) { if (AreEqual(item.Location, currentValue.Location)) { newFavorites.Add(newValue); } else { newFavorites.Add(item); } } var state = context.GetConversationState <Dictionary <string, object> >(); state[FavoritesKey] = newFavorites; }
// public int DeleteStock(int id) // { // lock (locker) { // return Delete<Stock> (new Stock () { Id = id }); // } // } public int DeleteFavoriteLocation(FavoriteLocation stock) { lock (locker) { return(Delete <FavoriteLocation> (stock.Id)); } }
public static int DeleteFavoriteLocation(FavoriteLocation item) { return(me.db.DeleteFavoriteLocation(item)); }
public static int SaveFavoriteLocation(FavoriteLocation item) { return(me.db.SaveFavoriteLocation(item)); }
public Task <int> DeleteItemAsync(FavoriteLocation loc) { return(Database.DeleteAsync(loc)); }
public Task <int> PostItemAsync(FavoriteLocation loc) { return(Database.InsertAsync(loc)); }