示例#1
0
 /// <summary>
 /// Saves an calendar entry to the database asyncronously
 /// </summary>
 /// <param name="entry">The calendar entry to store</param>
 /// <returns>An integer indicating the primary key of the calendar entry</returns>
 public async Task <int> SaveCalendarEntryAsync(RecipeCalendarEntry entry)
 {
     if (CalendarList != null && CalendarList.Any(e => e.Id == entry.Id))
     {
         return(await _database.UpdateAsync(entry));
     }
     else if (entry.Id != 0)
     {
         return(await _database.InsertOrReplaceAsync(entry));
     }
     else
     {
         return(await _database.InsertAsync(entry));
     }
 }
示例#2
0
        /// <summary>
        /// Catches the event when the time is set
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The arguments</param>
        private void OnTimeSet(object sender, TimeSetEventArgs e)
        {
            string[] datetime = ItemParser.ParseDateTimeForEntry(saveDate, e.HourOfDay, e.Minute);
            string   date     = datetime[0];
            string   time     = datetime[1];

            if (!string.IsNullOrWhiteSpace(time) && !string.IsNullOrWhiteSpace(date))
            {
                RecipeCalendarEntry entry = new RecipeCalendarEntry();
                entry.RecipeId = calendarRecipe.Id;
                entry.Time     = time;
                entry.Date     = date;
                CalendarFragment.ViewModel.AddCalendarEntryCommand.Execute(entry);
                calendarRecipe.CanDelete = false;
                Log.Debug("DateTime", date + time);
            }
        }
示例#3
0
        /// <summary>
        /// Handles the actions when an adapter item is longclicked
        /// </summary>
        /// <param name="sender">the adapter item</param>
        /// <param name="e">the event args</param>
        private void Adapter_ItemLongClick(object sender, RecyclerClickEventArgs e)
        {
            RecipeCalendarEntry entry = ViewModel.Calendar[selectedItem];

            AlertDialog.Builder confirmAlert = new AlertDialog.Builder(this.Activity);
            confirmAlert.SetTitle(BrowseRecipeFragment.ViewModel.Recipes[entry.RecipeId].Name);
            confirmAlert.SetMessage(GetString(Resource.String.calendar_confirmDelete));
            confirmAlert.SetPositiveButton(GetString(Resource.String.yes), (senderFromAlert, args) =>
            {
                selectedItem = e.Position;
                ViewModel.DeleteCalendarEntryCommand.Execute(entry);
                adapter.ShownEntries.Remove(entry);
                adapter.NotifyItemRemoved(selectedItem);
            });
            Dialog dialog = confirmAlert.Create();

            dialog.Show();
        }
示例#4
0
        /// <summary>
        /// Updates an ingredient
        /// </summary>
        /// <param name="ingredient">>the ingredient to update</param>
        /// <returns>the task</returns>
        async Task UpdateCalendarEntry(RecipeCalendarEntry entry)
        {
            RecipeCalendarEntry _entry = null;

            foreach (RecipeCalendarEntry cal in Calendar)
            {
                if (cal.Id == entry.Id)
                {
                    _entry = cal;
                    break;
                }
            }
            if (_entry != null)
            {
                Calendar.Remove(_entry);
                Calendar.Add(entry);
                await CalendarDataStore.UpdateItemAsync(entry);
            }
        }
示例#5
0
 /// <summary>
 /// Deletes a calendar entry from the database asyncronously
 /// </summary>
 /// <param name="entry">The calendar entry to delete</param>
 /// <returns>An integer indicating the deleted id</returns>
 public async Task <int> DeleteCalendarEntryAsync(RecipeCalendarEntry entry)
 {
     CalendarList.Remove(entry);
     return(await _database.DeleteAsync <RecipeCalendarEntry>(entry.Id));
 }
示例#6
0
 /// <summary>
 /// Deletes a calendar entry
 /// </summary>
 /// <param name="entry">>the entry to delete</param>
 /// <returns>the task</returns>
 async Task DeleteCalendarEntry(RecipeCalendarEntry entry)
 {
     Calendar.Remove(entry);
     await CalendarDataStore.DeleteItemAsync(entry.Id);
 }
示例#7
0
 /// <summary>
 /// Adds a calendar entry
 /// </summary>
 /// <param name="entry">the calendar entry to add</param>
 /// <returns>the task</returns>
 async Task AddCalendarEntry(RecipeCalendarEntry entry)
 {
     Calendar.Add(entry);
     await CalendarDataStore.AddItemAsync(entry);
 }