public async Task DeleteTest()
        {
            int result = await _ToDoItemService.Delete(1, 1);

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

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