Exemplo n.º 1
0
        public async void ChangeStateTodo(Guid id, TodoState state)
        {
            var todo = _context.Todo.Where(t => t.Id.Equals(id)).FirstOrDefault();

            todo.State = state;
            await _context.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public static TodoState OnAddTodo(TodoState state, AddTodo action)
        {
            var todoList = state.Todos.ToList();

            todoList.Add(action.Todo);
            return(new TodoState(todoList));
        }
Exemplo n.º 3
0
        public static TodoState OnToogleTodo(TodoState state, ToogleTodo action)
        {
            var todoList = state.Todos.ToList();

            todoList.First(x => x.Id == action.Todo.Id).Done = !action.Todo.Done;

            return(new TodoState(todoList));
        }
Exemplo n.º 4
0
        public void ObjectCloneTest()
        {
            var original = new TodoState();
            var cloned   = original.Copy();

            Assert.AreEqual(UnityEngine.JsonUtility.ToJson(original), UnityEngine.JsonUtility.ToJson(cloned));
            Assert.AreNotSame(original, cloned);
        }
Exemplo n.º 5
0
 public Todo(int id, string title, string description, DateTime deadline, TodoState state, int priority)
 {
     this.Id          = id;
     this.Deadline    = deadline;
     this.Title       = title;
     this.Description = description;
     this.State       = state;
     this.Priority    = priority;
 }
Exemplo n.º 6
0
 internal Todo(string name, string desc, DateTime?deadline = null)
 {
     this._Name        = name;
     this._Description = desc;
     this._Deadline    = deadline;
     this._State       = TodoState.Todo;
     this._ID          = CurrentID;
     CurrentID++;
 }
Exemplo n.º 7
0
        public void UpdateState(Guid id, TodoState state)
        {
            using (var context = new TodoItemContext())
            {
                var item = context.TodoItems.FirstOrDefault(i => i.Id == id);
                if (item == null)
                {
                    throw new ArgumentException("Todo Item not found", "id");
                }

                item.LastModificationDate = DateTime.Now;
                item.State = state;
                context.SaveChanges();
            }
        }
        public static TodoState Execute(TodoState previousState, IAction action)
        {
            if (action is ShowCompletedAction)
            {
                previousState.ShowCompleted = true;
            }

            if (action is ShowPendentAction)
            {
                previousState.ShowCompleted = false;
            }

            if (action is ToogleCompletedViewAction)
            {
                previousState.ShowCompleted = !previousState.ShowCompleted;
            }

            if (action is CompleteTodoAction c)
            {
                var todo = previousState.Todos.First(t => t.Id == c.Id);
                todo.Completed = true;
            }

            if (action is NewTodoAction newTodo)
            {
                var todo = new TodoItem()
                {
                    Id   = previousState.Todos.Max(x => x.Id) + 1,
                    Todo = newTodo.Todo
                };

                previousState.Todos.Add(todo);
            }

            return(previousState);
        }
Exemplo n.º 9
0
 public static TodoState SetVisibility(TodoState state, VisibilityFilter filter)
 {
     state.Filter = filter;
     state.SetStateChanged();
     return(state);
 }
Exemplo n.º 10
0
 public static TodoState OnRemoveTodo(TodoState state, RemoveTodo action)
 => new TodoState(state.Todos.Where(x => x.Id != action.Todo.Id).ToList());
 public RegisterNewTodoCommand(string description, TodoState estado, string file)
 {
     Description = description;
     State       = estado;
     File        = file;
 }
Exemplo n.º 12
0
 public Task()
 {
     State = new TodoState();
 }
Exemplo n.º 13
0
 public UpdateTodoCommand(string description, TodoState estado, string file)
 {
     Description = description;
     State       = estado;
     File        = file;
 }
Exemplo n.º 14
0
 public Todo(string description, TodoState state, string file)
 {
     Description = description;
     State       = state;
     File        = file;
 }