public async Task <ActionResult> InsertUpdateDoctorResidency(DoctorResidencyModel doctorResidency) { 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(doctorResidency.DoctorResidencyObject); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage Res = await client.PostAsync("api/DoctorAPI/InsertUpdateDoctorResidency", content); DoctorResidencyResponse result = new DoctorResidencyResponse(); if (Res.IsSuccessStatusCode) { result.IsSuccess = true; result.Message = Res.Content.ReadAsStringAsync().Result; } else { result.IsSuccess = false; result.Message = Res.Content.ReadAsStringAsync().Result; } return(View("DoctorResidencyResponse", result)); } }
public DoctorResidencyResponse GetDoctorResidencyList(int doctorId, int?doctorResidencyId) { try { Log.Info("Started call to GetDoctorResidencyList"); Log.Info("parameter values" + JsonConvert.SerializeObject(new { doctorId = doctorId, doctorResidencyId = doctorResidencyId })); Command.CommandText = "SP_GET_DOCTOR_RESIDENCY_LIST"; Command.CommandType = CommandType.StoredProcedure; Command.Parameters.Clear(); Command.Parameters.AddWithValue("@DOCTOR_ID", doctorId); if (doctorResidencyId.HasValue) { Command.Parameters.AddWithValue("@DOCTOR_RESIDENCY_ID", doctorResidencyId); } Connection.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(Command); DataSet ds = new DataSet(); dataAdapter.Fill(ds); DoctorResidencyResponse result = new DoctorResidencyResponse(); result.DoctorResidencyList = new List <DoctorResidencyDisplay>(); foreach (DataRow drDoctorResidency in ds.Tables[0].Rows) { result.DoctorResidencyList.Add(new DoctorResidencyDisplay { Id = Convert.ToInt32(drDoctorResidency["Id"].ToString()), DoctorId = Convert.ToInt32(drDoctorResidency["DoctorId"].ToString()), DoctorName = drDoctorResidency["DoctorName"] != DBNull.Value ? drDoctorResidency["DoctorName"].ToString() : null, BeginingYear = Convert.ToInt32(drDoctorResidency["BeginingYear"].ToString()), EndingYear = Convert.ToInt32(drDoctorResidency["EndingYear"].ToString()), HospitalName = drDoctorResidency["HospitalName"] != DBNull.Value ? drDoctorResidency["HospitalName"].ToString() : null, City = drDoctorResidency["City"] != DBNull.Value ? drDoctorResidency["City"].ToString() : null, StateId = Convert.ToInt32(drDoctorResidency["StateId"].ToString()), StateName = drDoctorResidency["StateName"] != DBNull.Value ? drDoctorResidency["StateName"].ToString() : null, CountryId = Convert.ToInt32(drDoctorResidency["CountryId"].ToString()), CountryName = drDoctorResidency["CountryName"] != DBNull.Value ? drDoctorResidency["CountryName"].ToString() : null, AddedBy = drDoctorResidency["AddedBy"] != DBNull.Value ? Convert.ToInt32(drDoctorResidency["AddedBy"].ToString()) : (int?)null, AddedDate = drDoctorResidency["AddedDate"] != DBNull.Value ? DateTime.Parse(drDoctorResidency["AddedDate"].ToString()) : (DateTime?)null, ModifiedBy = drDoctorResidency["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(drDoctorResidency["ModifiedBy"].ToString()) : (int?)null, ModifiedDate = drDoctorResidency["ModifiedDate"] != DBNull.Value ? DateTime.Parse(drDoctorResidency["ModifiedDate"].ToString()) : (DateTime?)null, }); } Log.Info("End call to GetDoctorResidencyList result " + JsonConvert.SerializeObject(result)); return(result); } catch (Exception ex) { throw; } finally { Connection.Close(); } }
public DoctorResidencyResponse InsertUpdateDoctorResidency(DoctorResidency doctorResidency, string operation) { try { Log.Info("Started call to InsertUpdateDoctorResidency"); Log.Info("parameter values" + JsonConvert.SerializeObject(new { doctorResidency = doctorResidency, operation = operation })); Command.CommandText = "SP_DOCTOR_RESIDENCY_MANAGER"; Command.CommandType = CommandType.StoredProcedure; Command.Parameters.Clear(); Command.Parameters.AddWithValue("@DOCTOR_RESIDENCY_XML", GetXMLFromObject(doctorResidency)); if (doctorResidency.AddedBy.HasValue) { Command.Parameters.AddWithValue("@USER_ID", doctorResidency.AddedBy.Value); } else if (doctorResidency.ModifiedBy.HasValue) { Command.Parameters.AddWithValue("@USER_ID", doctorResidency.ModifiedBy.Value); } Connection.Open(); SqlDataReader reader = Command.ExecuteReader(); DoctorResidencyResponse result = new DoctorResidencyResponse(); if (reader.HasRows) { while (reader.Read()) { result = new DoctorResidencyResponse { Message = reader["ReturnMessage"] != DBNull.Value ? reader["ReturnMessage"].ToString() : null, IsSuccess = Convert.ToBoolean(reader["Result"].ToString()) }; } } Log.Info("End call to InsertUpdateDoctorResidency"); return(result); } catch (Exception ex) { throw; } finally { Connection.Close(); } }