public List <SmartDetainee> Detainees(string term)
        {
            const string storedProcedureName = Constants.DetaineeSearch;

            using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString))
            {
                SqlCommand command = new SqlCommand(storedProcedureName, connection);
                command.CommandType = CommandType.StoredProcedure;


                command.Parameters.Add(Constants.term, SqlDbType.VarChar);
                command.Parameters[Constants.term].Value = term;

                connection.Open();

                SqlDataReader reader   = command.ExecuteReader();
                SmartDetainee detainee = null;

                List <SmartDetainee> detainees_list = new List <SmartDetainee>();
                while (reader.Read())
                {
                    detainee = new SmartDetainee
                    {
                        DetaineeID = Convert.ToInt32(reader.GetValue(0)),

                        Fullname = reader.GetValue(1).ToString()
                    };
                    detainees_list.Add(detainee);
                }
                connection.Close();
                return(detainees_list);
            }
        }
        public List <SmartDetainee> GetDetaineesByDetentionID(int id)
        {
            const string storedProcedureName = Constants.GetDetaineesByDetentionID;

            using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString))
            {
                SqlCommand command = new SqlCommand(storedProcedureName, connection);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.Add(Constants.DetentionID, SqlDbType.Int);
                command.Parameters[Constants.DetentionID].Value = id;

                connection.Open();
                SqlDataReader reader = command.ExecuteReader();

                SmartDetainee detainee = null;

                List <SmartDetainee> detainees_list = new List <SmartDetainee>();
                while (reader.Read())
                {
                    detainee                   = new SmartDetainee();
                    detainee.DetaineeID        = Convert.ToInt32(reader.GetValue(0));
                    detainee.Fullname          = reader.GetValue(1).ToString();
                    detainee.BirthDate         = Convert.ToDateTime(reader.GetValue(2));
                    detainee.MaritalStatus     = reader.GetValue(3).ToString();
                    detainee.Job               = reader.GetValue(4).ToString();
                    detainee.MobilePhoneNumber = reader.GetValue(5).ToString();
                    detainee.HomePhoneNumber   = reader.GetValue(6).ToString();
                    detainee.ResidencePlace    = reader.GetValue(7).ToString();
                    detainees_list.Add(detainee);
                }
                connection.Close();
                return(detainees_list);
            }
        }