public async Task <ActionResult> InsertUpdateDoctorResidency(DoctorResidencyModel doctorResidency)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(ConfigurationManager.AppSettings["BaseUrl"]);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                var json                = JsonConvert.SerializeObject(doctorResidency.DoctorResidencyObject);
                var content             = new StringContent(json, Encoding.UTF8, "application/json");
                HttpResponseMessage Res = await client.PostAsync("api/DoctorAPI/InsertUpdateDoctorResidency", content);

                DoctorResidencyResponse result = new DoctorResidencyResponse();
                if (Res.IsSuccessStatusCode)
                {
                    result.IsSuccess = true;
                    result.Message   = Res.Content.ReadAsStringAsync().Result;
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = Res.Content.ReadAsStringAsync().Result;
                }
                return(View("DoctorResidencyResponse", result));
            }
        }
        public async Task <ActionResult> DoctorResidency(int doctorId, int?doctorResidencyId, int userId)
        {
            var model = new DoctorResidencyModel
            {
                UserId = userId
            };

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(ConfigurationManager.AppSettings["BaseUrl"]);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage Res = await client.GetAsync("api/SignUpAPI/GetCountries?isActive=true");

                model.CountryList = JsonConvert.DeserializeObject <List <Country> >(Res.Content.ReadAsStringAsync().Result);

                if (doctorResidencyId.HasValue)
                {
                    Res = await client.GetAsync("api/DoctorAPI/GetDoctorResidencyList?doctorId=" + doctorId.ToString()
                                                + "&doctorResidencyId=" + doctorResidencyId.Value.ToString());

                    var doctorResidencyResponse = JsonConvert.DeserializeObject <DoctorResidencyResponse>(Res.Content.ReadAsStringAsync().Result);
                    if (doctorResidencyResponse.DoctorResidencyList != null &&
                        doctorResidencyResponse.DoctorResidencyList.Count() != 0)
                    {
                        model.DoctorResidencyObject            = doctorResidencyResponse.DoctorResidencyList.First();
                        model.DoctorResidencyObject.ModifiedBy = userId;
                        Res = await client.GetAsync("api/DoctorAPI/GetStates?isActive=true&countryId=" + model.DoctorResidencyObject.CountryId + "&stateId=");

                        model.StateList = JsonConvert.DeserializeObject <List <StateMaster> >(Res.Content.ReadAsStringAsync().Result);
                    }
                }
                else
                {
                    if (model.CountryList != null && model.CountryList.Count() != 0)
                    {
                        Res = await client.GetAsync("api/DoctorAPI/GetStates?isActive=true&countryId=" + model.CountryList.First().Id + "&stateId=");

                        model.StateList = JsonConvert.DeserializeObject <List <StateMaster> >(Res.Content.ReadAsStringAsync().Result);
                    }
                    model.DoctorResidencyObject = new DoctorResidency
                    {
                        DoctorId = doctorId,
                        AddedBy  = userId
                    };
                }
            }
            return(View("DoctorResidency", model));
        }