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 DoctorBoardResponse GetDoctorBoardList(int doctorId, int?doctorBoardId) { try { Log.Info("Started call to GetDoctorBoardList"); Log.Info("parameter values" + JsonConvert.SerializeObject(new { doctorId = doctorId, doctorBoardId = doctorBoardId })); Command.CommandText = "SP_GET_DOCTOR_BOARD_LIST"; Command.CommandType = CommandType.StoredProcedure; Command.Parameters.Clear(); Command.Parameters.AddWithValue("@DOCTOR_ID", doctorId); if (doctorBoardId.HasValue) { Command.Parameters.AddWithValue("@DOCTOR_BOARD_ID", doctorBoardId); } Connection.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(Command); DataSet ds = new DataSet(); dataAdapter.Fill(ds); DoctorBoardResponse result = new DoctorBoardResponse(); result.DoctorBoardList = new List <DoctorBoardDisplay>(); foreach (DataRow drDoctorBoard in ds.Tables[0].Rows) { result.DoctorBoardList.Add(new DoctorBoardDisplay { Id = Convert.ToInt32(drDoctorBoard["Id"].ToString()), DoctorId = Convert.ToInt32(drDoctorBoard["DoctorId"].ToString()), DoctorName = drDoctorBoard["DoctorName"] != DBNull.Value ? drDoctorBoard["DoctorName"].ToString() : null, BoardId = Convert.ToInt32(drDoctorBoard["BoardId"].ToString()), BoardName = drDoctorBoard["BoardName"] != DBNull.Value ? drDoctorBoard["BoardName"].ToString() : null, OtherDescription = drDoctorBoard["OtherDescription"] != DBNull.Value ? drDoctorBoard["OtherDescription"].ToString() : null, AddedBy = drDoctorBoard["AddedBy"] != DBNull.Value ? Convert.ToInt32(drDoctorBoard["AddedBy"].ToString()) : (int?)null, AddedDate = drDoctorBoard["AddedDate"] != DBNull.Value ? DateTime.Parse(drDoctorBoard["AddedDate"].ToString()) : (DateTime?)null, ModifiedBy = drDoctorBoard["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(drDoctorBoard["ModifiedBy"].ToString()) : (int?)null, ModifiedDate = drDoctorBoard["ModifiedDate"] != DBNull.Value ? DateTime.Parse(drDoctorBoard["ModifiedDate"].ToString()) : (DateTime?)null, }); } Log.Info("End call to GetDoctorBoardList result " + JsonConvert.SerializeObject(result)); return(result); } catch (Exception ex) { throw; } finally { Connection.Close(); } }
public DoctorBoardResponse InsertUpdateDoctorBoard(DoctorBoard doctorBoard, string operation) { try { Log.Info("Started call to InsertUpdateDoctorBoard"); Log.Info("parameter values" + JsonConvert.SerializeObject(new { doctorBoard = doctorBoard, operation = operation })); Command.CommandText = "SP_DOCTOR_BOARD_MANAGER"; Command.CommandType = CommandType.StoredProcedure; Command.Parameters.Clear(); Command.Parameters.AddWithValue("@DOCTOR_BOARD_XML", GetXMLFromObject(doctorBoard)); if (doctorBoard.AddedBy.HasValue) { Command.Parameters.AddWithValue("@USER_ID", doctorBoard.AddedBy.Value); } else if (doctorBoard.ModifiedBy.HasValue) { Command.Parameters.AddWithValue("@USER_ID", doctorBoard.ModifiedBy.Value); } Connection.Open(); SqlDataReader reader = Command.ExecuteReader(); DoctorBoardResponse result = new DoctorBoardResponse(); if (reader.HasRows) { while (reader.Read()) { result = new DoctorBoardResponse { Message = reader["ReturnMessage"] != DBNull.Value ? reader["ReturnMessage"].ToString() : null, IsSuccess = Convert.ToBoolean(reader["Result"].ToString()) }; } } Log.Info("End call to InsertUpdateDoctorBoard"); return(result); } catch (Exception ex) { throw; } finally { Connection.Close(); } }