/// <summary> /// Implements <see cref="IUserComicsHttpRepository.CreateUserComic"/>. /// </summary> public async Task <UserComic> CreateUserComic( Comic comic, StorageContainer storageContainer, string userId) { var fullUrl = $"{_comicApiConfig.ClientBaseUrl}/{EndpointsV1.UserComicsEndpointBase}/{userId}"; Logger.LogDebug("Making request to: {endpoint}", fullUrl); CreateUserComicRequest createUserComicRequest = new CreateUserComicRequest() { StorageContainer = storageContainer, Comic = comic }; var client = new HttpRequestClientBuilder <object>() .WithAbsoluteUrl(fullUrl) .WithRequestBody(createUserComicRequest) .WithRequestMethod(HttpMethod.Post) .WithHttpContextAccessor(_httpContextAccessor) .WithTokenClientSettings(_tokenClientSettings) .Build(); object response = await client.Send(); var comicResponse = JsonConvert.DeserializeObject <UserComic>(response.ToString()); Logger.LogDebug("Response returned: {response}", comicResponse); return(comicResponse); }
public async Task <UserComic> Create( // TODO: CREATE COMIC REQUEST TYPE [FromBody] CreateUserComicRequest createUserComicRequest, [FromRoute] string userId) { // TODO: Validation if (createUserComicRequest.Comic.Title is null) { throw new Exception("Title is required."); } _logger.LogDebug("**** Comic from body title: {title} ****", createUserComicRequest.Comic.Title); // Todo: add logging/exception handling var userComic = await _createUserComicAction.CreateUserComicAsync( createUserComicRequest.Comic, createUserComicRequest.StorageContainer, userId); return(userComic); }