コード例 #1
0
        public async Task CreateTodo()
        {
            var todo = await _accessor.HttpContext.Request.ReadJsonAsync <Todo>();

            _todoService.AddTodo(todo);
            _accessor.HttpContext.Response.StatusCode = 204;
        }
コード例 #2
0
        public Todo AddTodo([FromBody] Todo todo)
        {
            int id = _todoService.AddTodo(todo);

            todo.Id = id;
            return(todo);
        }
コード例 #3
0
        public IActionResult AddTodo([FromBody] CreateTodoReq req)
        {
            var claims = User.Identity as ClaimsIdentity;
            var data   = claims.Claims;
            var id     = int.Parse(data.First(s => s.Type == ClaimTypes.NameIdentifier).Value);

            _toDoService.AddTodo(id, req.Title);
            return(Ok());
        }
 public IActionResult Create(TodoDto model)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     todoService.AddTodo(model);
     return(RedirectToAction("List"));
 }
コード例 #5
0
 public IActionResult AddTodo([FromBody] Todo todo)
 {
     int.TryParse(User.Identity.Name, out int userId);
     if (_todoService.AddTodo(todo, userId))
     {
         return(Ok(todo));
     }
     return(BadRequest("There is something wrong with Todo info"));
 }
コード例 #6
0
ファイル: TodoController.cs プロジェクト: FISohan/dotnet_todo
        public async Task <IActionResult> AddTodoAsync(AddTodoDto newTodo)
        {
            ServiceResponse <List <Todo> > response = await _todoService.AddTodo(newTodo);

            if (!response.Success)
            {
                return(BadRequest(response.Message));
            }
            return(Ok(response.Message));
        }
コード例 #7
0
        public async Task <IActionResult> Post([FromBody] TodoUpsertModel todoUpsertModel)
        {
            var todo = _mapper.Map <TodoUpsertModel, BusinessModels.Todo>(todoUpsertModel);

            // Add newTodo
            var newTodoFromService = await _todoService.AddTodo(todo);

            // Map newTodo to apiModel
            var todoApiModel = _mapper.Map <BusinessModels.Todo, TodoModel>(newTodoFromService);

            // Return newTodo to client with the uri of the resource and created 201 result.
            return(CreatedAtAction(nameof(Get), new { todoApiModel.Id }, todoApiModel));
        }
コード例 #8
0
 public IActionResult AddTodo([FromQuery] string todoName)
 {
     if (String.IsNullOrEmpty(todoName))
     {
         return(BadRequest(new { message = "Name cannot be null" }));
     }
     _todosService.AddTodo(todoName, out var errorMessage);
     if (errorMessage != null)
     {
         return(BadRequest(new { message = errorMessage }));
     }
     return(Ok());
 }
コード例 #9
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            Todo task = GetTaskFromUI();

            if (_validate.IsValidTask(task))
            {
                _todoService.AddTodo(task);
                Close();
            }
            else
            {
                MessageBox.Show("DATA IS INVALID", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #10
0
        public string Post(int todolistid, [FromBody] JObject value)
        {
            var dict = value.ToObject <Dictionary <string, SerTodo> >();

            if (dict != null)
            {
                return(JsonConvert.SerializeObject(new StatusResponse
                {
                    Status = true,
                    NewItemId = _service.AddTodo(todolistid, dict["todo"])
                }));
            }
            return(StatusResponse.FalseResponse());
        }
コード例 #11
0
        public ActionResult <bool> Post(TodoItem item)
        {
            bool result = _TodoService.AddTodo(item);

            return(result);
        }
コード例 #12
0
        public async Task <IActionResult> AddTodo(string username, string title)
        {
            await todoService.AddTodo(title, username);

            return(RedirectToAction(nameof(TodoController.Todo), "Todo", new { username }));
        }
コード例 #13
0
 public IActionResult AddTodo(string title)
 {
     todoService.AddTodo(title);
     return(Redirect("/todo"));
 }
コード例 #14
0
        public async Task <IActionResult> AddTodo(Todos todo)
        {
            var response = await _todoService.AddTodo(todo);

            return(response.IsSuccess ? Ok(response) : (IActionResult)BadRequest(response));
        }
コード例 #15
0
 public ActionResult <Todo> Post([FromBody] Todo body)
 {
     return(Ok(_service.AddTodo(body)));
 }
コード例 #16
0
 public ActionResult <Todo> AddNewTodo([FromBody] Todo todo)
 {
     _todoService.AddTodo(todo);
     return(todo);
 }
コード例 #17
0
        public IActionResult AddTodo([FromBody] Todo todo)
        {
            var newTodo = _service.AddTodo(todo);

            return(Ok(newTodo));
        }
コード例 #18
0
        public async Task <ActionResult <TodoItemVm> > Create(CreateTodoItemRequest request)
        {
            var result = await _todoService.AddTodo(request.Name);

            return(Ok(result));
        }
コード例 #19
0
 public ActionResult <Todo> Post(Todo todo)
 {
     todo = _todoService.AddTodo(todo);
     return(CreatedAtAction(nameof(Get), new { id = todo.Id }, todo));
 }
コード例 #20
0
 public IActionResult AddTodo(Todo todo)
 {
     todoService.AddTodo(todo);
     return(RedirectToAction("List"));
 }
コード例 #21
0
 public IActionResult Create(Todo todo)
 {
     todo.IsDone = false;
     _todoService.AddTodo(todo);
     return(View(todo));
 }
コード例 #22
0
        public virtual IActionResult TodoPost([FromBody] Todo todo)
        {
            var created = todoService.AddTodo(todo);

            return(Created($"/todo/{todo.Id}", created));
        }