// POST: api/ToDos public HttpResponseMessage Post(ToDo toDo) { if (ModelState.IsValid) { _toDoService.CreateToDo(toDo); return(Request.CreateResponse(HttpStatusCode.Created, toDo)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, this.ModelState)); }
public async Task <IActionResult> CreateToDo([FromBody] ToDo todo) { var createdToDo = await _toDoService.CreateToDo(todo); if (createdToDo != null) { return(Ok(createdToDo)); //200 + data } return(NotFound()); //400 }
public ResponseMessage Post([FromBody] ToDo todo) { return(_service.CreateToDo(new CreateToDoRequest { Category = todo.Category, Description = todo.Description, EventDate = todo.EventDate, IsDone = todo.IsDone, Name = todo.Name, ReminderDate = todo.ReminderDate, Tag = todo.Tag })); }
public void Post([FromBody] ToDo value) { var userName = this.User.Identity.Name; _toDoService.CreateToDo(userName, value); }
public IActionResult CreateToDo([FromBody] ToDoDto toDo) { var results = _toDoService.CreateToDo(toDo); return(CreatedAtRoute("GetToDo", new { id = results.Id }, results)); }
public void Post([FromBody] ToDo value) { _toDoService.CreateToDo(value); }