public string SaveCountry(Countries acountry)
        {
            if (!countryGateway.ISCountryNameAlreadyExists(acountry))
            {
                if ((countryGateway.SaveCountryInfo(acountry) > 0))
                {
                    return "Country Information Saved Succesfully";

                }
                else
                {
                    return "Country Information Saving Failed";
                }
            }
            else
            {
                return "Country Name Already Exists";
            }
        }
 public List<Countries> GetAllCountry()
 {
     List<Countries> countryList=new List<Countries>();
     SqlConnection  connection=new SqlConnection(connectionString);
     string query = string.Format("SELECT * FROM Countries");
     //SqlDataAdapter adapter=new SqlDataAdapter();
     connection.Open();
     SqlCommand command=new SqlCommand(query,connection);
     //adapter.SelectCommand=new SqlCommand(query,connection);
     SqlDataReader reader = command.ExecuteReader();
     int serial = 1;
     while (reader.Read())
     {
         Countries aCountries=new Countries();
         aCountries.ID = serial;
         aCountries.Name = reader["Name"].ToString();
         aCountries.About = reader["About"].ToString();
         countryList.Add(aCountries);
         serial++;
     }
     reader.Close();
     connection.Close();
     return countryList;
 }
        public int SaveCountryInfo(Countries aCountry)
        {
            string query = string.Format("INSERT INTO Countries VALUES('{0}','{1}')",aCountry.Name,aCountry.About);
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            int rowAffected = command.ExecuteNonQuery();
            connection.Close();
            return rowAffected;
               // INSERT INTO Countries VALUES('{0}','{1}')", aCountry.Name, aCountry.About
        }
        public bool ISCountryNameAlreadyExists(Countries acountry)
        {
            bool isCountryNameAlreadyExists = false;
            string query = string.Format("Select * From Countries Where Name='{0}'", acountry.Name);
            SqlConnection connection = new SqlConnection(connectionString);

            SqlCommand command = new SqlCommand(query, connection);
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                isCountryNameAlreadyExists = true;
                break;
            }
            reader.Close();
            connection.Close();
            return isCountryNameAlreadyExists;
        }
        public List<Countries> PopulateDropDownList()
        {
            //List<Countries> countryList = new List<Countries>();
            //SqlConnection connection = new SqlConnection(connectionString);
            //string query = string.Format("SELECT * FROM Countries");
            ////SqlDataAdapter adapter=new SqlDataAdapter();
            //connection.Open();
            //SqlCommand command = new SqlCommand(query, connection);
            ////adapter.SelectCommand=new SqlCommand(query,connection);
            //SqlDataReader reader = command.ExecuteReader();
            //connection.Close();
            //return reader;
            List<Countries> countryList = new List<Countries>();
            SqlConnection connection = new SqlConnection(connectionString);
            string query = string.Format("SELECT * FROM Countries");
            //SqlDataAdapter adapter=new SqlDataAdapter();
            connection.Open();
            SqlCommand command = new SqlCommand(query, connection);
            //adapter.SelectCommand=new SqlCommand(query,connection);
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Countries aCountries = new Countries();
                aCountries.ID = Convert.ToInt32(reader["ID"]);
                aCountries.Name = reader["Name"].ToString();
                aCountries.About = reader["About"].ToString();
                countryList.Add(aCountries);

            }
            reader.Close();
            connection.Close();
            return countryList;
        }