예제 #1
0
        public IActionResult AfterAdd(string newTodo)
        {
            todoService.AddNewTodo(new Todo()
            {
                Title = newTodo
            });
            var todos = applicationContext.Todos.ToList();

            return(RedirectToAction(nameof(Index), "Todo", todos));
        }
예제 #2
0
        public async Task <IActionResult> Post([FromBody] ToDo todo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ResponseMessage()
                {
                    Status = false, Error = "مقادیر اشتباه است"
                }));
            }

            _todoService.AddNewTodo(todo);
            _todoService.Save();
            return(Ok(new ResponseMessage()
            {
                Message = "با موفقیت ذخیره شد",
                Status = true
            }));
        }
예제 #3
0
 public IActionResult AddTodo(Todo todo)
 {
     todoService.AddNewTodo(todo);
     return(Redirect("list"));
 }
 public IActionResult AddNewTodo(Todo todo)
 {
     todoService.AddNewTodo(todo);
     return(RedirectToAction(actionName: nameof(Index)));
 }