public async Task CreateTodo() { var todo = await _accessor.HttpContext.Request.ReadJsonAsync <Todo>(); _todoService.AddTodo(todo); _accessor.HttpContext.Response.StatusCode = 204; }
public Todo AddTodo([FromBody] Todo todo) { int id = _todoService.AddTodo(todo); todo.Id = id; return(todo); }
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")); }
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")); }
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)); }
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()); }
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); } }
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()); }
public ActionResult <bool> Post(TodoItem item) { bool result = _TodoService.AddTodo(item); return(result); }
public async Task <IActionResult> AddTodo(string username, string title) { await todoService.AddTodo(title, username); return(RedirectToAction(nameof(TodoController.Todo), "Todo", new { username })); }
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)); }
public ActionResult <Todo> Post([FromBody] Todo body) { return(Ok(_service.AddTodo(body))); }
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)); }
public async Task <ActionResult <TodoItemVm> > Create(CreateTodoItemRequest request) { var result = await _todoService.AddTodo(request.Name); return(Ok(result)); }
public ActionResult <Todo> Post(Todo todo) { todo = _todoService.AddTodo(todo); return(CreatedAtAction(nameof(Get), new { id = todo.Id }, todo)); }
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)); }
public virtual IActionResult TodoPost([FromBody] Todo todo) { var created = todoService.AddTodo(todo); return(Created($"/todo/{todo.Id}", created)); }