public async Task <ActionResult> InsertUpdateDoctorAward(DoctorAwardModel doctorAward)
        {
            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(doctorAward.DoctorAwardObject);
                var content             = new StringContent(json, Encoding.UTF8, "application/json");
                HttpResponseMessage Res = await client.PostAsync("api/DoctorAPI/InsertUpdateDoctorAward", content);

                DoctorAwardsResponse result = new DoctorAwardsResponse();
                if (Res.IsSuccessStatusCode)
                {
                    result.IsSuccess = true;
                    result.Message   = Res.Content.ReadAsStringAsync().Result;
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = Res.Content.ReadAsStringAsync().Result;
                }
                return(View("DoctorAwardResponse", result));
            }
        }
Exemple #2
0
        public DoctorAwardsResponse GetDoctorAwardList(int doctorId, int?doctorAwardId)
        {
            try
            {
                Log.Info("Started call to GetDoctorAwardList");
                Log.Info("parameter values" + JsonConvert.SerializeObject(new { doctorId = doctorId, doctorAwardId = doctorAwardId }));
                Command.CommandText = "SP_GET_DOCTOR_AWARD_LIST";
                Command.CommandType = CommandType.StoredProcedure;
                Command.Parameters.Clear();

                Command.Parameters.AddWithValue("@DOCTOR_ID", doctorId);
                if (doctorAwardId.HasValue)
                {
                    Command.Parameters.AddWithValue("@DOCTOR_AWARD_ID", doctorAwardId);
                }
                Connection.Open();

                SqlDataAdapter dataAdapter = new SqlDataAdapter(Command);
                DataSet        ds          = new DataSet();
                dataAdapter.Fill(ds);
                DoctorAwardsResponse result = new DoctorAwardsResponse();
                result.DoctorAwardsList = new List <DoctorAwardsDisplay>();
                foreach (DataRow drDoctorAward in ds.Tables[0].Rows)
                {
                    result.DoctorAwardsList.Add(new DoctorAwardsDisplay
                    {
                        Id              = Convert.ToInt32(drDoctorAward["Id"].ToString()),
                        DoctorId        = Convert.ToInt32(drDoctorAward["DoctorId"].ToString()),
                        DoctorName      = drDoctorAward["DoctorName"] != DBNull.Value ? drDoctorAward["DoctorName"].ToString() : null,
                        YearReceived    = Convert.ToInt32(drDoctorAward["YearReceived"].ToString()),
                        InstitutionName = drDoctorAward["InstitutionName"] != DBNull.Value ? drDoctorAward["InstitutionName"].ToString() : null,
                        AwardName       = drDoctorAward["AwardName"] != DBNull.Value ? drDoctorAward["AwardName"].ToString() : null,
                        AddedBy         = drDoctorAward["AddedBy"] != DBNull.Value ? Convert.ToInt32(drDoctorAward["AddedBy"].ToString()) : (int?)null,
                        AddedDate       = drDoctorAward["AddedDate"] != DBNull.Value ? DateTime.Parse(drDoctorAward["AddedDate"].ToString()) : (DateTime?)null,
                        ModifiedBy      = drDoctorAward["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(drDoctorAward["ModifiedBy"].ToString()) : (int?)null,
                        ModifiedDate    = drDoctorAward["ModifiedDate"] != DBNull.Value ? DateTime.Parse(drDoctorAward["ModifiedDate"].ToString()) : (DateTime?)null,
                    });
                }
                Log.Info("End call to GetDoctorAwardList result " + JsonConvert.SerializeObject(result));

                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                Connection.Close();
            }
        }
Exemple #3
0
        public DoctorAwardsResponse InsertUpdateDoctorAward(DoctorAwards doctorAward, string operation)
        {
            try
            {
                Log.Info("Started call to InsertUpdateDoctorAward");
                Log.Info("parameter values" + JsonConvert.SerializeObject(new { doctorAward = doctorAward, operation = operation }));
                Command.CommandText = "SP_DOCTOR_AWARD_MANAGER";
                Command.CommandType = CommandType.StoredProcedure;
                Command.Parameters.Clear();

                Command.Parameters.AddWithValue("@DOCTOR_AWARD_XML", GetXMLFromObject(doctorAward));
                if (doctorAward.AddedBy.HasValue)
                {
                    Command.Parameters.AddWithValue("@USER_ID", doctorAward.AddedBy.Value);
                }
                else if (doctorAward.ModifiedBy.HasValue)
                {
                    Command.Parameters.AddWithValue("@USER_ID", doctorAward.ModifiedBy.Value);
                }
                Connection.Open();
                SqlDataReader reader = Command.ExecuteReader();

                DoctorAwardsResponse result = new DoctorAwardsResponse();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        result = new DoctorAwardsResponse
                        {
                            Message   = reader["ReturnMessage"] != DBNull.Value ? reader["ReturnMessage"].ToString() : null,
                            IsSuccess = Convert.ToBoolean(reader["Result"].ToString())
                        };
                    }
                }
                Log.Info("End call to InsertUpdateDoctorAward");

                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                Connection.Close();
            }
        }