public static async Task SaveTask (TodoTask task) { var token = SessionData.Resolve<AccessToken>(); if (task.id == null) { await Users.createTodoTask (task, token.userID); } else { await Users.updateByIdTodoTask (task, token.userID, task.id); } ResetCache (); }
private async void OnDelete(TodoTask task){ await TaskHelper.DeleteTask (task); }
private async void OnFavorite(TodoTask task){ await TaskHelper.ToggleFavorite (task); }
private async void OnTaskSaved(TodoTask task){ if (task.IsValid ()) { await TaskHelper.SaveTask (task); popupLayout.DismissPopup (); UpdateList (); } else { await DisplayAlert ("Error", "Please make sure you filled in all task fields", "OK"); ShowPopup (task); } }
private async void OnDone(TodoTask task){ await TaskHelper.ToggleDone (task); }
public TodoTaskViewModel(TodoTask task) { TodoTask = task; }
private void UpdateTask(TodoTask task) { task.date = datePicker.SelectedDate + timePicker.Time; task.category = categoryPicker.SelectedCategory.Name; task.isFavorite = isFavorite; UpdateTitle (); }
public async static Task ToggleFavorite(TodoTask task){ var token = SessionData.Resolve<AccessToken>(); task.isFavorite = !task.isFavorite; await Users.updateByIdTodoTask (task, token.userID, task.id); ResetCache(); }
public void Test0050() { #region テストデータ準備 var testEntityBeforeUpdate = TestUtilLib.GenarateRandomTodoTask(); var testEntityOfUpdate = TestUtilLib.GenarateRandomTodoTask(); var testEntityOfAdd1 = TestUtilLib.GenarateRandomTodoTask(); var testEntityOfAdd2 = new TodoTask(); testEntityOfUpdate.TodoTaskId = testEntityBeforeUpdate.TodoTaskId; testEntityOfUpdate.DueDate = testEntityBeforeUpdate.DueDate.Value.AddMinutes(1); using (var context = new EfDbContext()) { context.Add(testEntityBeforeUpdate); context.SaveChanges(); } using (var context = new EfDbContext()) Assert.AreEqual(1, context.TodoTasks.Count()); #endregion TodoTask dbEntity; Assert.AreEqual(1, DalTodoTask.Upsert(testEntityOfUpdate)); #region データを取得し、結果を確認(全て一致するはず(レコード登録日時、レコード更新日時 は比較除外)) using (var context = new EfDbContext()) dbEntity = context.TodoTasks.Find(testEntityOfUpdate.TodoTaskId); foreach (var property in testEntityOfUpdate.GetType().GetProperties()) { switch (property.Name) { case nameof(testEntityOfUpdate.TodoTaskId): Assert.AreEqual(property.GetValue(testEntityBeforeUpdate), property.GetValue(dbEntity)); Assert.AreEqual(property.GetValue(testEntityOfUpdate), property.GetValue(dbEntity)); break; case nameof(testEntityOfUpdate.CreateDateTime): case nameof(testEntityOfUpdate.UpdateDateTime): break; default: Assert.AreNotEqual(property.GetValue(testEntityBeforeUpdate), property.GetValue(dbEntity)); Assert.AreEqual(property.GetValue(testEntityOfUpdate), property.GetValue(dbEntity)); break; } } #endregion Assert.AreEqual(1, DalTodoTask.Upsert(testEntityOfAdd1)); #region データを取得し、結果を確認(全て一致するはず(レコード登録日時、レコード更新日時 は比較除外)) using (var context = new EfDbContext()) dbEntity = context.TodoTasks.Find(testEntityOfAdd1.TodoTaskId); foreach (var property in testEntityOfAdd1.GetType().GetProperties()) { switch (property.Name) { case nameof(testEntityOfAdd1.CreateDateTime): case nameof(testEntityOfAdd1.UpdateDateTime): Assert.AreNotEqual(property.GetValue(testEntityOfAdd1), property.GetValue(dbEntity)); break; default: Assert.AreEqual(property.GetValue(testEntityOfAdd1), property.GetValue(dbEntity)); break; } } #endregion Assert.AreEqual(1, DalTodoTask.Upsert(testEntityOfAdd2)); #region データを取得し、結果を確認(全て一致するはず(レコード登録日時、レコード更新日時 は比較除外)) using (var context = new EfDbContext()) dbEntity = context.TodoTasks.Find(testEntityOfAdd2.TodoTaskId); foreach (var property in testEntityOfAdd2.GetType().GetProperties()) { switch (property.Name) { case nameof(testEntityOfAdd2.CreateDateTime): case nameof(testEntityOfAdd2.UpdateDateTime): Assert.AreNotEqual(property.GetValue(testEntityOfAdd2), property.GetValue(dbEntity)); break; default: Assert.AreEqual(property.GetValue(testEntityOfAdd2), property.GetValue(dbEntity)); break; } } #endregion }
public async Task UpdateStatusTodoTask(TodoTask todoTaskToBeUpdated, TodoTask todoTask) { todoTaskToBeUpdated.IsActive = todoTask.IsActive; todoTaskToBeUpdated.LastModifiedDate = todoTask.LastModifiedDate; await _unitOfWork.CommitAsync(); }
public async Task DeleteTodoTask(TodoTask todoTask) { _unitOfWork.TodoTasks.Remove(todoTask); await _unitOfWork.CommitAsync(); }
public TodoTaskViewModel(TodoTask todoTask) { this.TodoTask = todoTask; }
public void DeleteTask(TodoTask task) { TodoTasks.Remove(task); }
public TodoTaskDetailViewModel(TodoTask todo) { Todo = todo; }
public void ShowPopup(TodoTask task) { FadeIn (); popup = new TaskPopup( task, popupLayout.DismissPopup, () => OnTaskSaved(popup.Task)); Debug.WriteLine("ShowPopup"); popupLayout.ReliableShowPopup(popup, popupLayout, PopupLayout.PopupLocation.Top, 0, 25); popup.OnPopupShown(); }
public async static Task DeleteTask(TodoTask task){ var token = SessionData.Resolve<AccessToken>(); task.isDeleted = true; await Users.updateByIdTodoTask (task, token.userID, task.id); ResetCache(); }
public void UpdateTask(TodoTask item) { _context.SaveChanges(); }
public AddTaskResult(TodoTask task, StatusEnum status) : base(status) { Task = task; }
public void Add(TodoTask entity) { _todoTaskRepository.Add(entity); }
public TaskPopup( TodoTask task, Action onCancel = null, Action onSubmit = null) { Task = task; SelectedDate = task.date; timePicker.Time = task.date.TimeOfDay; BackgroundColor = StyleManager.MainColor; WidthRequest = 300; titleLabel = new DefaultLabel {Text = Task.title, HorizontalOptions = LayoutOptions.CenterAndExpand}; titleEdit = new DefaultEntry {Text = Task.title, HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.Transparent}; titleEdit.WidthRequest = 250; var editButton = new Image {HorizontalOptions = LayoutOptions.End, Source = "edit_task.png"}; var doneButton = new Image {HorizontalOptions = LayoutOptions.End, Source = "ok.png"}; titlePanel = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 10, Children = {titleLabel, editButton} }; var editPanel = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(10, 0), Children = {titleEdit, doneButton} }; topPanel = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand, Content = titlePanel, }; editButton.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.BeginInvokeOnMainThread (() => { topPanel.Content = editPanel; titleEdit.Focus (); })) }); doneButton.GestureRecognizers.Add (new TapGestureRecognizer { Command = new Command (() => Device.BeginInvokeOnMainThread (UpdateTitle)) }); if (string.IsNullOrWhiteSpace (task.title)) { Device.BeginInvokeOnMainThread(() => { topPanel.Content = editPanel; titleEdit.Focus(); ((Entry)editPanel.Children [0]).Focus (); }); ((Entry)editPanel.Children [0]).Focus (); } popupFragment = new ContentView(); datePicker = new PopupDatePicker { OnItemSelected = view => { if (view != null){ popupFragment.Content = view; } } }; datePicker.DateChanged += (sender, e) => { SelectedDate = datePicker.SelectedDate; }; popupFragment.Content = datePicker.DefaultView; var categoryIcon = new Image {HorizontalOptions = LayoutOptions.EndAndExpand, HeightRequest = 12, Source = task.GetCategory().IconSource}; categoryPicker = new CategoryPicker(); categoryPicker.SelectedIndex = 0; foreach (Category category in CategoryHelper.AllCategories) { categoryPicker.Items.Add (category.Name); if (task.category == category.Name) { categoryPicker.SelectedIndex = categoryPicker.Items.Count - 1; } } categoryPicker.SelectedIndexChanged += ( sender, args ) => categoryIcon.Source = CategoryHelper.AllCategories[categoryPicker.SelectedIndex].IconSource; var selectCategoryArrow = new Image { HorizontalOptions = LayoutOptions.End, Source = "select.png", HeightRequest = 10 }; selectCategoryArrow.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => categoryPicker.Focus ()) }); var categoryLayout = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new DefaultLabel {Text = "Category", TextColor = StyleManager.MainColor}, categoryIcon, categoryPicker, selectCategoryArrow } }; isFavorite = task.isFavorite; var starResource = isFavorite ? FAVORITE_IMG : NOT_FAVORITE_IMG; var favoriteLabel = new DefaultLabel { Text = "Mark as favorite", TextColor = StyleManager.MainColor }; var favoriteImage = new Image { HorizontalOptions = LayoutOptions.EndAndExpand, Source = starResource, HeightRequest = 15 }; var favoriteLayout = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { favoriteLabel, favoriteImage} }; favoriteImage.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.BeginInvokeOnMainThread (() => { isFavorite = !isFavorite; favoriteImage.Source = isFavorite ? FAVORITE_IMG : NOT_FAVORITE_IMG; })) }); var actionText = "Create"; if (!string.IsNullOrWhiteSpace (task.title)) actionText = "Update"; var buttons = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 0, Children = { new DefaultButton { Text = "Cancel", TextColor = Color.White, BackgroundColor = Color.Silver, HorizontalOptions = LayoutOptions.FillAndExpand, Command = new Command (onCancel.Dispatch) }, new DefaultButton { Text = actionText, TextColor = Color.White, BackgroundColor = StyleManager.MainColor, HorizontalOptions = LayoutOptions.FillAndExpand, Command = new Command (() => Device.BeginInvokeOnMainThread (() => { UpdateTask (task); onSubmit.Dispatch (); })) } } }; var mainLayout = new StackLayout { Padding = 15, BackgroundColor = StyleManager.AccentColor, Spacing = 20, Children = { // TODO time picker, pass time timePicker, categoryLayout, favoriteLayout, buttons } }; Children.Add(topPanel); Children.Add(datePicker); Children.Add(popupFragment); Children.Add(mainLayout); }
public Task <int> DeleteTask(TodoTask item) { return(db.DeleteAsync(item)); }