示例#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
            }));
        }
 public IActionResult AddTodo(Todo todo)
 {
     todoService.AddNewTodo(todo);
     return(Redirect("list"));
 }
 public IActionResult AddNewTodo(Todo todo)
 {
     todoService.AddNewTodo(todo);
     return(RedirectToAction(actionName: nameof(Index)));
 }