public ObservableCollection <FoodItem> Refresh() { hasError = false; ObservableCollection <FoodItem> fooditems = new ObservableCollection <FoodItem>(); try { FoodItemLINQDataContext dc = new FoodItemLINQDataContext(); var query = from q in dc.MenuItems select new sqlFoodItem { Id = q.ItemId, FoodName = q.FoodName, ItemPrice = Convert.ToDecimal(q.Price1) }; foreach (sqlFoodItem sp in query) { fooditems.Add(sp.sqlFoodItem2FoodItem()); } } catch (Exception ex) { errorMessage = "Refresh() error, " + ex.Message; hasError = true; } return(fooditems); }
public bool Save(FoodItem selectedFoodItem) { hasError = false; try { sqlFoodItem f = new sqlFoodItem(selectedFoodItem); FoodItemLINQDataContext dc = new FoodItemLINQDataContext(); dc.UpdateFoodItem(selectedFoodItem.FoodName, selectedFoodItem.ItemPrice, selectedFoodItem.Id); } catch (Exception ex) { errorMessage = "Update error, " + ex.Message; hasError = true; } return(!hasError); }