/// <summary>
        /// Regsiters the lotted lunch menu.
        /// </summary>
        /// <param name="selectedItem">Selected item.</param>
        private void regsiterLottedLunchMenu(LunchMenuPickerItem selectedItem)
        {
            var newMenuLog = new MenuLog(selectedItem.id, selectedItem.calory, selectedItem.cost);

            // Dismiss dialog on succeeding insert.
            if (LunchMenuDao.getInstance().insertMenuLog((newMenuLog)))
            {
                // TODO

                /*
                 * string successText = String.Format(Resources.GetString (Resource.String.success_add_log), 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();
                 */
            }
            Dismiss();
        }
        /// <summary>
        /// Check if the content of the new menu log is valid to insert.
        /// </summary>
        /// <returns><c>true</c>, if new menu log was validated, <c>false</c> otherwise.</returns>
        /// <param name="menuLog">Menu log data to validate.</param>
        public bool validateNewMenuLog(MenuLog menuLog)
        {
            lock (locker) {
                DateTime startDay = DateTimeUtils.getStartOfDay(menuLog.created);
                DateTime endDay   = DateTimeUtils.getEndOfDay(menuLog.created);

                SQLiteCommand cmd   = dbConn.CreateCommand(CHECK_NEW_LOG_FORMAT, startDay, endDay);
                int           count = Convert.ToInt32(cmd.ExecuteScalar <Int32> ());

                return(validateMenuLog(menuLog) && count == 0);
            }
        }
 /// <summary>
 /// Check if the content of the menu is valid..
 /// </summary>
 /// <returns><c>true</c>, if new menu log format is correct, <c>false</c> otherwise.</returns>
 /// <param name="menuLog">Menu log data to insert.</param>
 public bool insertMenuLog(MenuLog menuLog)
 {
     if (validateNewMenuLog(menuLog))
     {
         lock (locker) {
             dbConn.Insert(menuLog);
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
Example #4
0
        /**
         * Add new lunch menu log.
         */
        private void regsiterLunchMenu(int menuId, string name, float calory, float cost)
        {
            var newMenuLog = new MenuLog(menuId, calory, cost);

            // Dismiss dialog on succeeding insert.
            if (LunchMenuDao.getInstance().insertMenuLog((newMenuLog)))
            {
                Dismiss();
                string successText = String.Format(Resources.GetString(Resource.String.success_add_log), 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 log is valid.
 /// </summary>
 /// <returns><c>true</c>, if menu log was validated, <c>false</c> otherwise.</returns>
 /// <param name="menuLog">Menu log data to validate.</param>
 private bool validateMenuLog(MenuLog menuLog)
 {
     return(menuLog.calory >= 0 && menuLog.cost >= 0);
 }