Esempio n. 1
0
        public async Task DeleteToDoItemTest()
        {
            int result = await _ToDoItemContract.DeleteToDoItem(1, 1);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result);
        }
Esempio n. 2
0
        public async Task <IActionResult> DeleteToDoItem([Required] long id)
        {
            long userId          = long.Parse(HttpContext.Items["UserId"].ToString());
            int  deletedToDoItem = await _toDoItemContract.DeleteToDoItem(id, userId);

            if (deletedToDoItem == 1)
            {
                return(Ok(
                           new ApiResponse <object>
                {
                    IsSuccess = true,
                    Result = "Deleted",
                    Message = "ToDoItem with ID = " + id + "is deleted by UserId = " + userId + "."
                }));
            }
            return(NotFound(
                       new ApiResponse <string>
            {
                IsSuccess = true,
                Result = "Not found.",
                Message = "No data exist for Id = " + id + "."
            }));
        }