public async Task UpdateToDoListTest()
        {
            ToDoListDto result = await _toDoListContract.UpdateToDoList(new UpdateToDoListDto());

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ToDoListId);
        }
Beispiel #2
0
        public async Task <IActionResult> PutToDoList(UpdateToDoListModel listToUpdate)
        {
            long userId = long.Parse(HttpContext.Items["UserId"].ToString());

            if (null == listToUpdate || string.IsNullOrWhiteSpace(listToUpdate.Description))
            {
                return(BadRequest(new ApiResponse <string>
                {
                    IsSuccess = false,
                    Result = "Not Updated.",
                    Message = "Please enter correct values. Description should not be empty."
                }));
            }

            UpdateToDoListDto listToUpdateDto    = _mapper.Map <UpdateToDoListDto>(listToUpdate);
            ToDoListDto       updatedToDoListDto = await _toDoListContract.UpdateToDoList(listToUpdateDto);

            ToDoListModel updatedToDoList = _mapper.Map <ToDoListModel>(updatedToDoListDto);

            if (updatedToDoList != null)
            {
                return(Ok(
                           new ApiResponse <ToDoListModel>
                {
                    IsSuccess = true,
                    Result = updatedToDoList,
                    Message = "ToDoList with Id = " + updatedToDoList.ToDoListId + " is updated on " + updatedToDoList.UpdationDate + " by UserId = " + userId + "."
                }));
            }
            return(NotFound(
                       new ApiResponse <object>
            {
                IsSuccess = false,
                Result = "Item to be updated not found.",
                Message = "No data exist for ToDoListId = " + listToUpdate.ToDoListId
            }));
        }