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