/// <summary> /// Check if the menu is valid to insert. /// </summary> /// <returns><c>true</c>, if new menu was validated, <c>false</c> otherwise.</returns> /// <param name="menu">Lunch Menu data to validate.</param> public bool validateNewMenu(LunchMenu menu) { lock (locker) { SQLiteCommand cmd = dbConn.CreateCommand(CHECK_NEW_FORMAT, menu.name); int count = Convert.ToInt32(cmd.ExecuteScalar <Int32> ()); return(validateMenu(menu) && count == 0); } }
public LunchMenuListItem(LunchMenu menu, int count, Drawable image) { this.id = menu.id; this.name = menu.name; this.calory = menu.calory; this.cost = menu.cost; this.selectedCount = count; this.image = image; }
/// <summary> /// Check if the menu is valid to update. /// </summary> /// <returns><c>true</c>, if update menu was validated, <c>false</c> otherwise.</returns> /// <param name="menu">Lunch Menu data to validate.</param> public bool validateUpdateMenu(LunchMenu menu) { lock (locker) { SQLiteCommand cmd = dbConn.CreateCommand(CHECK_EXIST_FORMAT, menu.id); int existCount = Convert.ToInt32(cmd.ExecuteScalar <Int32> ()); cmd = dbConn.CreateCommand(CHECK_DUPLICATE_FORMAT, menu.id, menu.name); int dupliateCount = Convert.ToInt32(cmd.ExecuteScalar <Int32> ()); return(validateMenu(menu) && existCount == 1 && dupliateCount == 0); } }
/// <summary> /// Insert new menu. /// </summary> /// <returns><c>true</c>, if menu format is correct, <c>false</c> otherwise.</returns> /// <param name="menu">Lunch Menu data to insert.</param> public bool insertMenu(LunchMenu menu) { if (validateNewMenu(menu)) { lock (locker) { dbConn.Insert(menu); return(true); } } else { return(false); } }
/// <summary> /// Update lunch menu database element. /// </summary> /// <returns><c>true</c>, if menu format is correct. <c>false</c> otherwise.</returns> /// <param name="menu">Lunch menu data to update</param> public bool updateMenu(LunchMenu menu) { if (validateUpdateMenu(menu)) { lock (locker) { dbConn.Update(menu); return(true); } } else { return(false); } }
/** * Add new lunch menu. */ private void addLunchMenu(String name, float calory, float cost) { var newMenu = new LunchMenu(name, calory, cost); // Dismiss dialog on succeeding insert. if (LunchMenuDao.getInstance().insertMenu(newMenu)) { Dismiss(); string successText = String.Format(Resources.GetString(Resource.String.success_add_menu), name); Toast.MakeText(Activity, successText, ToastLength.Short).Show(); } else { // TODO // Show failure Toast and Highlight invalid field. string successText = String.Format(Resources.GetString(Resource.String.fail_add_menu), name); Toast.MakeText(Activity, successText, ToastLength.Short).Show(); } }
/// <summary> /// Check if the content of the menu is valid. /// </summary> /// <returns><c>true</c>, if menu was validated, <c>false</c> otherwise.</returns> /// <param name="menu">Lunch menu data to validate.</param> public bool validateMenu(LunchMenu menu) { return(menu.calory >= 0 && menu.cost >= 0 && !menu.deleted); }
public LunchMenuPickerItem(LunchMenu menu, int count, Drawable image) : base(menu, count, image) { }