Exemplo n.º 1
0
        public void NewToDo(string title)
        {
            ToDoRepository toDoRepos = new ToDoRepository(_connectionString);
            ToDo           toDo      = new ToDo {
                Title = title, IsCompleted = false,
            };

            toDoRepos.AddToDo(toDo);
            SendTasks();
        }
Exemplo n.º 2
0
        public void AddTodo_ByDefault_ReturnsToDosCollection()
        {
            var toDo = new ToDo
            {
                Date = It.IsAny <DateTime>(),
                Task = It.IsAny <string>()
            };

            var result = _toDoRepository.AddToDo
                             (toDo, Guid.Parse("12f97655-1c02-4724-ae34-96db34561310"));

            Assert.IsAssignableFrom <ICollection <ToDo> >(result);
        }
Exemplo n.º 3
0
        public ViewResult NewToDo(ToDo toDo)
        {
            // Here we have the logics to save/post the new todo entered but the user when they click a save button for example.

            if (ModelState.IsValid)
            {
                // Sending the users added info to our Repository.
                ToDoRepository.AddToDo(toDo);


                /* This is using View(string viewName, object model) two parameters.
                 * First parameter = name of the view we want to show.
                 * Second parameter = send the new To Do as the model to the view. */
                return(View("ToDoAdded", toDo));
            }
            else
            {
                // Something is wrong with the model. Will return the original NewToDo.cshtml view.
                return(View());
            }
        }