예제 #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
        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));
        }
        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"));
 }
        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);
 }
        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"));
 }
 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));
        }