/// <summary> /// 登録されているTodoの数を確認する処理 /// </summary> /// <returns></returns> public int CheckCountRegisteredToDo() { using (TodoList_ManagerEntities context = new TodoList_ManagerEntities()) { return(registeredToDoCount = (context.TodoList.Select(b => b).Count())); } }
/// <summary> /// Todoリストが空ではないときの処理 /// </summary> public void TodoListContentEmptyNotOnProcess() { using (TodoList_ManagerEntities context = new TodoList_ManagerEntities()) { newRegister_TodoId = (context.TodoList.Select(b => b.Todo_id).Max()) + 1; } }
/// <summary> /// 全てのTodoをTodoリストから削除する処理 /// </summary> public void RemoveAllTodo() { using (TodoList_ManagerEntities context = new TodoList_ManagerEntities()) { context.Database.ExecuteSqlCommand("DELETE FROM TodoList"); } }
/// <summary> /// 最後に追加されたTodoを削除する処理 /// </summary> public void RemoveTodoAddedLast() { using (TodoList_ManagerEntities context = new TodoList_ManagerEntities()) { int todoAddedLast = context.TodoList.Select(b => b.Todo_id).Max(); var todoRemove = context.TodoList.Single(x => x.Todo_id == todoAddedLast); context.TodoList.Remove(todoRemove); context.SaveChanges(); } }
/// <summary> /// Todoリストの中身を確認する処理 /// </summary> public void CheckTodoListContent() { using (TodoList_ManagerEntities context = new TodoList_ManagerEntities()) { CheckCountRegisteredToDo(); //int currentMax_TodoId; if (registeredToDoCount == 0) { TodoListContentEmptyOnProcess(); } else if (registeredToDoCount >= 1) { TodoListContentEmptyNotOnProcess(); } } }
/// <summary> /// 入力したTodoをTodoリストに登録する処理 /// </summary> public void RegisterInputedToDo() { DateTime toDay = DateTime.Now; using (TodoList_ManagerEntities context = new TodoList_ManagerEntities()) { CheckTodoListContent(); context.TodoList.Add(new TodoList { Todo_id = newRegister_TodoId, Todo_title = TextBox_Title.Text, Add_date = toDay, Todo_contents = TextBox_Contexts.Text, Adding_member = TextBox_Member.Text }); context.SaveChanges(); } }