public async Task TestCreateBookmarkAndGetById() { Assert.NotNull(context); // create one item var itemId = NewId; var item = await repo.Create(new BookmarkEntity { Id = itemId, ChildCount = 0, Created = DateTime.UtcNow, DisplayName = "displayName", Path = "/", SortOrder = 0, Type = ItemType.Node, Url = "http://url", UserName = Username }); Assert.NotNull(item); Assert.Equal(itemId, item.Id); Assert.Equal("displayName", item.DisplayName); Assert.Equal(Username, item.UserName); // get item by id var bm = await repo.GetBookmarkById(itemId, Username); Assert.NotNull(bm); Assert.Equal(itemId, item.Id); Assert.Equal("displayName", bm.DisplayName); Assert.Equal(Username, bm.UserName); }
public async Task <ActionResult> GetById(string id) { if (string.IsNullOrEmpty(id)) { return(InvalidArguments($"Invalid id supplid")); } _logger.LogDebug($"Try to fetch bookmark by id '{id}'"); var user = this.User.Get(); var bookmark = await _repository.GetBookmarkById(id, user.Username); if (bookmark == null || string.IsNullOrEmpty(bookmark.Id)) { _logger.LogWarning($"could not get bookmark by id '{id}'"); return(ProblemDetailsResult( statusCode: StatusCodes.Status404NotFound, title: Errors.NotFoundError, detail: $"No bookmark with given id '{id}' found.", instance: HttpContext.Request.Path )); } return(Ok(ToModel(bookmark))); }