public async Task <IActionResult> PostFoodRestrictions([FromBody] FoodRestrictionsRequest request, CancellationToken cancellationToken) { try { var result = await this._userService.PostFoodRestrictions(request); return(Ok(result)); } catch (Exception ex) { //log return(StatusCode(StatusCodes.Status400BadRequest, string.Format("Error trying to post food restrictions: {0}", ex.Message))); } }
public virtual async Task <FoodRestrictionsResponse> PostFoodRestrictions(FoodRestrictionsRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var response = new FoodRestrictionsResponse(); try { var serviceResult = await _options.PostFoodRestrictions .WithHeader("Cache-Control", "no-cache") .PostJsonAsync(request, cancellationToken); response = JsonConvert.DeserializeObject <FoodRestrictionsResponse>(serviceResult.Content.ReadAsStringAsync().Result); } catch (Exception ex) { throw ex; } return(response); }