예제 #1
0
        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());
        }
예제 #2
0
        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));
        }
예제 #3
0
 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));
 }
예제 #6
0
        public async Task <ActionResult <TodoItem> > PostTodoItem(TodoItem item)
        {
            var response = await _service.CreateTodoItem(item);

            return(response);
        }
예제 #7
0
        public async Task <TodoItem> AddTodoItem(TodoItemDTO todoItem)
        {
            var todoItemInput = _mapper.Map <TodoItemDTO, TodoItem>(todoItem);

            return(await _todoItemService.CreateTodoItem(todoItemInput));
        }