public async Task <IActionResult> CreateTodoItem(long listId, [FromBody] TodoItemCreateModel value) { var result = await _todoItemService.CreateTodoItem(listId, value); if (result != null) { return(CreatedAtAction(nameof(GetTodoItem), new { id = result.Id }, result)); } return(BadRequest()); }
public async Task <ActionResult <TodoItem> > PostTodoItem(SaveTodoItemDTO todoItemDTO) { var todoItem = _mapper.Map <SaveTodoItemDTO, TodoItem>(todoItemDTO); if (todoItem.Description == null) { return(BadRequest(new { message = "TodoItem Description mandatory" })); } await _todoItemService.CreateTodoItem(todoItem); return(CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem)); }
public IActionResult AddTodo(string newItemDescription, string searchString, bool?isCompleted, int page, int pageSize) { try { todoItemService.CreateTodoItem(this.HttpContext.User.Identity.Name, newItemDescription); return(Index(searchString, isCompleted, page, pageSize)); } catch (Exception ex) { _logger.LogError(ex.Message); return(Error()); } }
public void CreateTodoItem([FromBody] TodoItemViewModel todoItem) { var list = _todoListService.GetTodoListById(todoItem.TodoListEntityId); if (list == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } if (list.ApplicationUserEntityId != User.Identity.GetUserId()) { throw new HttpResponseException(HttpStatusCode.Forbidden); } _todoItemService.CreateTodoItem(_mapper.Map <TodoItemViewModel, TodoItemDTO>(todoItem)); }
public async Task <SingleResponseModel <int> > CreateTodoItem([FromBody] CreateOrUpdateTodoItemRequestModel request) { return(await _todoItemService.CreateTodoItem(request)); }
public async Task <ActionResult <TodoItem> > PostTodoItem(TodoItem item) { var response = await _service.CreateTodoItem(item); return(response); }
public async Task <TodoItem> AddTodoItem(TodoItemDTO todoItem) { var todoItemInput = _mapper.Map <TodoItemDTO, TodoItem>(todoItem); return(await _todoItemService.CreateTodoItem(todoItemInput)); }