public async Task <ActionResult> InsertUpdateDoctorEducation(DoctorEducationModel doctorEducation) { 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(doctorEducation.DoctorEducationObject); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage Res = await client.PostAsync("api/DoctorAPI/InsertUpdateDoctorEducation", content); DoctorEducationResponse result = new DoctorEducationResponse(); if (Res.IsSuccessStatusCode) { result.IsSuccess = true; result.Message = Res.Content.ReadAsStringAsync().Result; } else { result.IsSuccess = false; result.Message = Res.Content.ReadAsStringAsync().Result; } return(View("DoctorEducationResponse", result)); } }
public async Task <ActionResult> DoctorEducation(int doctorId, int?doctorEducationId, int userId) { var model = new DoctorEducationModel { 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 (doctorEducationId.HasValue) { Res = await client.GetAsync("api/DoctorAPI/GetDoctorEducationList?doctorId=" + doctorId.ToString() + "&doctorEducationId=" + doctorEducationId.Value.ToString()); var doctorEducationResponse = JsonConvert.DeserializeObject <DoctorEducationResponse>(Res.Content.ReadAsStringAsync().Result); if (doctorEducationResponse.DoctorEducationList != null && doctorEducationResponse.DoctorEducationList.Count() != 0) { model.DoctorEducationObject = doctorEducationResponse.DoctorEducationList.First(); model.DoctorEducationObject.ModifiedBy = userId; Res = await client.GetAsync("api/DoctorAPI/GetStates?isActive=true&countryId=" + model.DoctorEducationObject.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.DoctorEducationObject = new DoctorEducation { DoctorId = doctorId, AddedBy = userId }; } } return(View("DoctorEducation", model)); }