public void DoWork(int versionNumber) { var todoItem = new CreateTodo() { Value = $"V{versionNumber}. This is a scheduled task that posts every 5 minutes." }; _todoService.CreateTodoItem(todoItem); }
public ActionResult <int> CreateTodoItem(string content) { int ret = _service.CreateTodoItem(content); if (ret < 0) { return(BadRequest()); } return(Ok(ret)); }
public IHttpActionResult CreateItem(TodoItem model) { if (string.IsNullOrWhiteSpace(model.Title)) { return(BadRequest("標題必須輸入")); } _todoService.CreateTodoItem(model); return(Ok()); }
public ActionResult Post([FromBody] TodoItemViewModel item) { try { var userId = _todoService.CreateTodoItem(item); return(Ok(userId)); } catch (Exception ex) { return(BadRequest(new { message = ex.Message })); } }
public ActionResult CreateTodoItem([FromBody] CreateTodo todoItem) { try { var todo = _todoService.CreateTodoItem(todoItem); return(Created(Request.Path.Value, todo)); } catch (Exception ex) { _logger.LogError(ex, "Unhandled exception occurred (HTTP 500): {0} {2}{3}", Request.Method, Request.Path, Request.QueryString); return(StatusCode((int)HttpStatusCode.InternalServerError, "Unexpected error occured")); } }
public TodoController(ITodoService todoService) { _todoService = todoService; var listAsync = _todoService.GetTodoItemList(); var list = listAsync.Result; if (list.Count == 0) { // Create a new TodoItem if collection is empty, // which means you can't delete all TodoItems. _todoService.CreateTodoItem(new TodoItem { Name = "Item1" }); } }
public async Task <ActionResult <TodoItem> > PostTodoItem(TodoItem item) { await _todoService.CreateTodoItem(item); return(CreatedAtAction(nameof(GetTodoItem), new { id = item.Id }, item)); }
public async Task <ActionResult <TodoItem> > CreateTodoItem(TodoItem todoItem) { _service.CreateTodoItem(todoItem); return(CreatedAtAction(nameof(GetTodoItemById), new { id = todoItem.Id }, todoItem)); }
public async Task <IActionResult> Post([FromBody] TodoItemViewModel model) { var response = await _todoService.CreateTodoItem(model); return(Ok(response)); }
public void Post([FromBody] Todo value) { _todoService.CreateTodoItem(value); }
public void Post([FromBody] Todo value) { value.User = HttpContext.User.Identity.Name; _todoService.CreateTodoItem(value); }
public async Task <ActionResult <TodoItem> > CreateTodoItem(TodoItem todoItem) { return(_todoService.CreateTodoItem(todoItem)); }