Example #1
0
        public async Task GetToDoItemById()
        {
            ToDoItemDto result = await _ToDoItemContract.GetToDoItemById(1, 1);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ToDoItemId);
        }
Example #2
0
        public async Task <IActionResult> GetToDoItemById([Required] long toDoItemId)
        {
            long userId = long.Parse(HttpContext.Items["UserId"].ToString());

            ToDoItemDto ToDoItemDto = await _toDoItemContract.GetToDoItemById(toDoItemId, userId);

            if (ToDoItemDto != null)
            {
                return(Ok(
                           new ApiResponse <ToDoItemDto>
                {
                    IsSuccess = true,
                    Result = ToDoItemDto,
                    Message = "Item retrieval successful."
                }));
            }
            return(NotFound(
                       new ApiResponse <string>
            {
                IsSuccess = false,
                Result = "Not found.",
                Message = "No data exist for Id = " + toDoItemId + "."
            }));
        }