Beispiel #1
0
        public async Task Like(SurveyLikeModel surveyLikeModel, string authenticationToken)
        {
            try
            {
                LikeService likeService = new LikeService();

                var response = await likeService.Like(surveyLikeModel, authenticationToken).ConfigureAwait(false);

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception(response.StatusCode.ToString() + " - " + response.ReasonPhrase);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #2
0
        public async Task <HttpResponseMessage> Like(SurveyLikeModel surveyLikeModel, string authenticationToken)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    var formContent = new StringContent(JsonConvert.SerializeObject(surveyLikeModel, new JsonSerializerSettings()
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    }), Encoding.UTF8, "application/json");

                    client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer " + authenticationToken);
                    return(await client.PostAsync(EnvironmentConstants.getServerUrl() + "api/survey/like", formContent));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }