public async Task <ActionResult> InsertUpdateDoctorAward(DoctorAwardModel doctorAward) { 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(doctorAward.DoctorAwardObject); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage Res = await client.PostAsync("api/DoctorAPI/InsertUpdateDoctorAward", content); DoctorAwardsResponse result = new DoctorAwardsResponse(); if (Res.IsSuccessStatusCode) { result.IsSuccess = true; result.Message = Res.Content.ReadAsStringAsync().Result; } else { result.IsSuccess = false; result.Message = Res.Content.ReadAsStringAsync().Result; } return(View("DoctorAwardResponse", result)); } }
public async Task <ActionResult> DoctorAward(int doctorId, int?doctorAwardId, int userId) { var model = new DoctorAwardModel { 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")); if (doctorAwardId.HasValue) { HttpResponseMessage Res = await client.GetAsync("api/DoctorAPI/GetDoctorAwardList?doctorId=" + doctorId.ToString() + "&doctorAwardId=" + doctorAwardId.Value.ToString()); var doctorAwardsResponse = JsonConvert.DeserializeObject <DoctorAwardsResponse>(Res.Content.ReadAsStringAsync().Result); if (doctorAwardsResponse.DoctorAwardsList != null && doctorAwardsResponse.DoctorAwardsList.Count() != 0) { model.DoctorAwardObject = doctorAwardsResponse.DoctorAwardsList.First(); model.DoctorAwardObject.ModifiedBy = userId; } } else { model.DoctorAwardObject = new DoctorAwards { DoctorId = doctorId, AddedBy = userId }; } } return(View("DoctorAward", model)); }