public async Task <ActionResult> Delete(int doctorProfileId, int userId) { 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(new { doctorProfileId = doctorProfileId, userId = userId }); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage Res = await client.PostAsync("api/DoctorAPI/DeleteDoctorProfile?doctorProfileId=" + doctorProfileId + "&userId=" + userId, content); DoctorProfileResponse result = new DoctorProfileResponse(); if (Res.IsSuccessStatusCode) { result.IsSuccess = true; result.Message = Res.Content.ReadAsStringAsync().Result; } else { result.IsSuccess = false; result.Message = Res.Content.ReadAsStringAsync().Result; } return(Json(result, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> InsertUpdate(DoctorModel doctor) { 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(doctor.DoctorProfileObject); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage Res = await client.PostAsync("api/DoctorAPI/InsertUpdateDoctorProfile", content); DoctorProfileResponse result = new DoctorProfileResponse(); if (Res.IsSuccessStatusCode) { result.IsSuccess = true; result.Message = Res.Content.ReadAsStringAsync().Result; } else { result.IsSuccess = false; result.Message = Res.Content.ReadAsStringAsync().Result; } return(View("DoctorProfileResponse", result)); } }
public DoctorProfileResponse InsertUpdateDoctorProfile(DoctorProfile doctorProfile, string operation) { try { Log.Info("Started call to InsertUpdateDoctorProfile"); Log.Info("parameter values" + JsonConvert.SerializeObject(new { doctorProfile = doctorProfile, operation = operation })); Command.CommandText = "SP_DOCTOR_PROFILE_MANAGER"; Command.CommandType = CommandType.StoredProcedure; Command.Parameters.Clear(); Command.Parameters.AddWithValue("@DOCTOR_PROFILE_XML", GetXMLFromObject(doctorProfile)); if (!string.IsNullOrEmpty(operation)) { Command.Parameters.AddWithValue("@OPERATION", operation); } if (doctorProfile.AddedBy.HasValue) { Command.Parameters.AddWithValue("@USER_ID", doctorProfile.AddedBy.Value); } else if (doctorProfile.ModifiedBy.HasValue) { Command.Parameters.AddWithValue("@USER_ID", doctorProfile.ModifiedBy.Value); } Connection.Open(); SqlDataReader reader = Command.ExecuteReader(); DoctorProfileResponse result = new DoctorProfileResponse(); if (reader.HasRows) { while (reader.Read()) { result = new DoctorProfileResponse { Message = reader["ReturnMessage"] != DBNull.Value ? reader["ReturnMessage"].ToString() : null, IsSuccess = Convert.ToBoolean(reader["Result"].ToString()) }; } } Log.Info("End call to InsertUpdateDoctorProfile"); return(result); } catch (Exception ex) { throw; } finally { Connection.Close(); } }
public DoctorProfileResponse DeleteDoctorProfile(int doctorProfileId, int userId) { try { Log.Info("Started call to DeleteDoctorProfile"); Log.Info("parameter values" + JsonConvert.SerializeObject(new { doctorProfileId = doctorProfileId, userId = userId })); Command.CommandText = "SP_DOCTOR_PROFILE_MANAGER"; Command.CommandType = CommandType.StoredProcedure; Command.Parameters.Clear(); var doctorProfile = new DoctorProfile { Id = doctorProfileId, DeletedBy = userId }; Command.Parameters.AddWithValue("@DOCTOR_PROFILE_XML", GetXMLFromObject(doctorProfile)); Command.Parameters.AddWithValue("@OPERATION", "SOFT_DELETE"); Connection.Open(); SqlDataReader reader = Command.ExecuteReader(); DoctorProfileResponse result = new DoctorProfileResponse(); if (reader.HasRows) { while (reader.Read()) { result = new DoctorProfileResponse { Message = reader["ReturnMessage"] != DBNull.Value ? reader["ReturnMessage"].ToString() : null, IsSuccess = Convert.ToBoolean(reader["Result"].ToString()) }; } } Log.Info("End call to DeleteDoctorProfile"); return(result); } catch (Exception ex) { throw; } finally { Connection.Close(); } }