public async Task GetByIdTest()
        {
            ToDoItemDto result = await _ToDoItemService.GetById(1, 1);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ToDoItemId);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetById([Required] int id)
        {
            int userId = int.Parse(HttpContext.Items["UserId"].ToString());

            ToDoItemDto ToDoItemDto = await _itemService.GetById(id, userId);

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