public ApiResponseModel <User> GetById([FromBody] GetByIdRequestModel requestModel) { var responseModel = new ApiResponseModel <User>(); try { responseModel.Data = _userService.GetById(requestModel.Id); responseModel.ResultStatusCode = ResultStatusCodeStatic.Success; responseModel.ResultStatusMessage = "Success"; } catch (Exception ex) { responseModel.ResultStatusCode = ResultStatusCodeStatic.Error; responseModel.ResultStatusMessage = ex.Message; } return(responseModel); }
public ApiResponseModel <Movies> GetById(string userToken, int id) { ApiResponseModel <Movies> result = new ApiResponseModel <Movies>(); using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(ConfigHelper.ApiUrl); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userToken); var portalApiRequestModel = new GetByIdRequestModel(); portalApiRequestModel.UserToken = userToken; portalApiRequestModel.Id = id; HttpResponseMessage response = httpClient.PostAsJsonAsync(string.Format("Movies/GetById"), portalApiRequestModel).Result; result = response.Content.ReadAsAsync <ApiResponseModel <Movies> >().Result; } return(result); }