public async Task AddToDoListTest() { ToDoListDto result = await _toDoListService.Add(new CreateToDoListDto()); Assert.IsNotNull(result); Assert.AreEqual(1, result.ToDoListId); }
public async Task <IActionResult> Add(CreateToDoListDto createToDoList, ApiVersion version) { int userId = int.Parse(HttpContext.Items["UserId"].ToString()); if (createToDoList == null || string.IsNullOrWhiteSpace(createToDoList.Description)) { return(BadRequest(new ResponseModel <string> { IsSuccess = false, Result = "Not Updated.", Message = "Invalid request, mandatory fields not provided in request." })); } createToDoList.CreatedBy = userId; createToDoList.UserId = userId; ToDoListDto createdToDoList = await _listService.Add(createToDoList); return(CreatedAtAction(nameof(GetById), new { id = createdToDoList.ToDoListId, version = $"{version}" }, createdToDoList)); }