Beispiel #1
0
        public async Task <GenericResponse <AddRatingModel> > AddEndorsements(AddRatingModel addRatingModel)
        {
            GenericResponse <AddRatingModel> savedUserResponse = new GenericResponse <AddRatingModel>();
            HttpResponseMessage response = null;
            var uri = new Uri(string.Format(ApiPath.PostRating(), string.Empty));

            try
            {
                var        json    = JsonConvert.SerializeObject(addRatingModel);
                var        content = new StringContent(json, Encoding.UTF8, "application/json");
                HttpClient _client = new HttpClient();
                response = await _client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    var respContent = await response.Content.ReadAsStringAsync();

                    savedUserResponse = JsonConvert.DeserializeObject <GenericResponse <AddRatingModel> >(respContent);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(savedUserResponse);
        }