public async Task <ActionResult> InsertUpdateDoctorBoard(DoctorBoardModel doctorBoard) { 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(doctorBoard.DoctorBoardObject); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage Res = await client.PostAsync("api/DoctorAPI/InsertUpdateDoctorBoard", content); DoctorBoardResponse result = new DoctorBoardResponse(); if (Res.IsSuccessStatusCode) { result.IsSuccess = true; result.Message = Res.Content.ReadAsStringAsync().Result; } else { result.IsSuccess = false; result.Message = Res.Content.ReadAsStringAsync().Result; } return(View("DoctorBoardResponse", result)); } }
public async Task <ActionResult> DoctorBoard(int doctorId, int?doctorBoardId, int userId) { var model = new DoctorBoardModel { 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/DoctorAPI/GetBoards?isActive=true&boardId=&board="); model.BoardList = JsonConvert.DeserializeObject <List <BoardMaster> >(Res.Content.ReadAsStringAsync().Result); if (doctorBoardId.HasValue) { Res = await client.GetAsync("api/DoctorAPI/GetDoctorBoardList?doctorId=" + doctorId.ToString() + "&doctorBoardId=" + doctorBoardId.Value.ToString()); var doctorBoardResponse = JsonConvert.DeserializeObject <DoctorBoardResponse>(Res.Content.ReadAsStringAsync().Result); if (doctorBoardResponse.DoctorBoardList != null && doctorBoardResponse.DoctorBoardList.Count() != 0) { model.DoctorBoardObject = doctorBoardResponse.DoctorBoardList.First(); model.DoctorBoardObject.ModifiedBy = userId; } } else { model.DoctorBoardObject = new DoctorBoard { DoctorId = doctorId, AddedBy = userId }; } } return(View("DoctorBoard", model)); }