public async Task <ActionResult> InsertUpdateDoctorFellowship(DoctorFellowshipModel doctorFellowship) { 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(doctorFellowship.DoctorFellowshipObject); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage Res = await client.PostAsync("api/DoctorAPI/InsertUpdateDoctorFellowship", content); DoctorFellowshipResponse result = new DoctorFellowshipResponse(); if (Res.IsSuccessStatusCode) { result.IsSuccess = true; result.Message = Res.Content.ReadAsStringAsync().Result; } else { result.IsSuccess = false; result.Message = Res.Content.ReadAsStringAsync().Result; } return(View("DoctorFellowshipResponse", result)); } }
public async Task <ActionResult> DoctorFellowship(int doctorId, int?doctorFellowshipId, int userId) { var model = new DoctorFellowshipModel { 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 (doctorFellowshipId.HasValue) { Res = await client.GetAsync("api/DoctorAPI/GetDoctorFellowshipList?doctorId=" + doctorId.ToString() + "&doctorFellowshipId=" + doctorFellowshipId.Value.ToString()); var doctorFellowshipResponse = JsonConvert.DeserializeObject <DoctorFellowshipResponse>(Res.Content.ReadAsStringAsync().Result); if (doctorFellowshipResponse.DoctorFellowshipList != null && doctorFellowshipResponse.DoctorFellowshipList.Count() != 0) { model.DoctorFellowshipObject = doctorFellowshipResponse.DoctorFellowshipList.First(); model.DoctorFellowshipObject.ModifiedBy = userId; Res = await client.GetAsync("api/DoctorAPI/GetStates?isActive=true&countryId=" + model.DoctorFellowshipObject.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.DoctorFellowshipObject = new DoctorFellowship { DoctorId = doctorId, AddedBy = userId }; } } return(View("DoctorFellowship", model)); }