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 DoctorFellowshipResponse GetDoctorFellowshipList(int doctorId, int?doctorFellowshipId) { try { Log.Info("Started call to GetDoctorFellowshipList"); Log.Info("parameter values" + JsonConvert.SerializeObject(new { doctorId = doctorId, doctorFellowshipId = doctorFellowshipId })); Command.CommandText = "SP_GET_DOCTOR_FELLOWSHIP_LIST"; Command.CommandType = CommandType.StoredProcedure; Command.Parameters.Clear(); Command.Parameters.AddWithValue("@DOCTOR_ID", doctorId); if (doctorFellowshipId.HasValue) { Command.Parameters.AddWithValue("@DOCTOR_FELLOWSHIP_ID", doctorFellowshipId); } Connection.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(Command); DataSet ds = new DataSet(); dataAdapter.Fill(ds); DoctorFellowshipResponse result = new DoctorFellowshipResponse(); result.DoctorFellowshipList = new List <DoctorFellowshipDisplay>(); foreach (DataRow drDoctorFellowship in ds.Tables[0].Rows) { result.DoctorFellowshipList.Add(new DoctorFellowshipDisplay { Id = Convert.ToInt32(drDoctorFellowship["Id"].ToString()), DoctorId = Convert.ToInt32(drDoctorFellowship["DoctorId"].ToString()), DoctorName = drDoctorFellowship["DoctorName"] != DBNull.Value ? drDoctorFellowship["DoctorName"].ToString() : null, BeginingYear = Convert.ToInt32(drDoctorFellowship["BeginingYear"].ToString()), EndingYear = Convert.ToInt32(drDoctorFellowship["EndingYear"].ToString()), HospitalName = drDoctorFellowship["HospitalName"] != DBNull.Value ? drDoctorFellowship["HospitalName"].ToString() : null, City = drDoctorFellowship["City"] != DBNull.Value ? drDoctorFellowship["City"].ToString() : null, StateId = Convert.ToInt32(drDoctorFellowship["StateId"].ToString()), StateName = drDoctorFellowship["StateName"] != DBNull.Value ? drDoctorFellowship["StateName"].ToString() : null, CountryId = Convert.ToInt32(drDoctorFellowship["CountryId"].ToString()), CountryName = drDoctorFellowship["CountryName"] != DBNull.Value ? drDoctorFellowship["CountryName"].ToString() : null, AddedBy = drDoctorFellowship["AddedBy"] != DBNull.Value ? Convert.ToInt32(drDoctorFellowship["AddedBy"].ToString()) : (int?)null, AddedDate = drDoctorFellowship["AddedDate"] != DBNull.Value ? DateTime.Parse(drDoctorFellowship["AddedDate"].ToString()) : (DateTime?)null, ModifiedBy = drDoctorFellowship["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(drDoctorFellowship["ModifiedBy"].ToString()) : (int?)null, ModifiedDate = drDoctorFellowship["ModifiedDate"] != DBNull.Value ? DateTime.Parse(drDoctorFellowship["ModifiedDate"].ToString()) : (DateTime?)null, }); } Log.Info("End call to GetDoctorFellowshipList result " + JsonConvert.SerializeObject(result)); return(result); } catch (Exception ex) { throw; } finally { Connection.Close(); } }
public DoctorFellowshipResponse InsertUpdateDoctorFellowship(DoctorFellowship doctorFellowship, string operation) { try { Log.Info("Started call to InsertUpdateDoctorFellowship"); Log.Info("parameter values" + JsonConvert.SerializeObject(new { doctorFellowship = doctorFellowship, operation = operation })); Command.CommandText = "SP_DOCTOR_FELLOWSHIP_MANAGER"; Command.CommandType = CommandType.StoredProcedure; Command.Parameters.Clear(); Command.Parameters.AddWithValue("@DOCTOR_FELLOWSHIP_XML", GetXMLFromObject(doctorFellowship)); if (doctorFellowship.AddedBy.HasValue) { Command.Parameters.AddWithValue("@USER_ID", doctorFellowship.AddedBy.Value); } else if (doctorFellowship.ModifiedBy.HasValue) { Command.Parameters.AddWithValue("@USER_ID", doctorFellowship.ModifiedBy.Value); } Connection.Open(); SqlDataReader reader = Command.ExecuteReader(); DoctorFellowshipResponse result = new DoctorFellowshipResponse(); if (reader.HasRows) { while (reader.Read()) { result = new DoctorFellowshipResponse { Message = reader["ReturnMessage"] != DBNull.Value ? reader["ReturnMessage"].ToString() : null, IsSuccess = Convert.ToBoolean(reader["Result"].ToString()) }; } } Log.Info("End call to InsertUpdateDoctorFellowship"); return(result); } catch (Exception ex) { throw; } finally { Connection.Close(); } }