Пример #1
0
        public async Task <HospitalRate> SaveRate(int id, int answer)
        {
            DataService  service = new DataService();
            HospitalRate hr      = new HospitalRate();

            hr.User_ID               = _userID;
            hr.Hospital_ID           = _hospitalId;
            hr.Hospital_Quistions_ID = id;
            hr.Answer = answer.ToString();

            HospitalRate hr1 = await service.createhosrate(hr);

            return(hr1);
        }
Пример #2
0
        internal async Task <HospitalRate> createhosrate(HospitalRate hr1)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://slamtk1.somee.com/api/odata/HospitalRateGet");



            var json = JsonConvert.SerializeObject(hr1);

            var content          = new StringContent(json, Encoding.UTF8, "application/json");
            HttpRequestMessage h = new HttpRequestMessage();

            h.Content    = content;
            h.Method     = HttpMethod.Post;
            h.RequestUri = client.BaseAddress;


            HttpResponseMessage response = await client.SendAsync(h);

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

                var result = JsonConvert.DeserializeObject <HospitalRate>(response1);
                return(result);
            }
            else
            {
                HospitalRate us2 = new HospitalRate()
                {
                    Hospital_Quistions_ID = 0,
                };
                return(us2);
            }
        }