Ejemplo n.º 1
0
		public Country ToModel(SqlDataReader reader)
		{
			Country country = new Country();

			country.CountryId = (int)ToModelValue(reader,"CountryId");
			country.CountryName = (string)ToModelValue(reader,"CountryName");
			country.LocalName = (string)ToModelValue(reader,"LocalName");
			country.WebCode = (string)ToModelValue(reader,"WebCode");
			country.Region = (string)ToModelValue(reader,"Region");
			country.Continent = (string)ToModelValue(reader,"Continent");
			country.Latitude = (double)ToModelValue(reader,"Latitude");
			country.Longitude = (double)ToModelValue(reader,"Longitude");
			country.SurfaceArea = (double)ToModelValue(reader,"SurfaceArea");
			country.Population = (long)ToModelValue(reader,"Population");
			return country;
		}
Ejemplo n.º 2
0
        public int Update(Country country)
        {
            string sql = "UPDATE Countries SET CountryName=@CountryName,LocalName=@LocalName,WebCode=@WebCode,Region=@Region,Continent=@Continent,Latitude=@Latitude,Longitude=@Longitude,SurfaceArea=@SurfaceArea,Population=@Population WHERE CountryId = @CountryId"; 
            
			SqlParameter[] para = new SqlParameter[]
			{
				new SqlParameter("@CountryId", country.CountryId)
					,new SqlParameter("@CountryName", ToDBValue(country.CountryName))
					,new SqlParameter("@LocalName", ToDBValue(country.LocalName))
					,new SqlParameter("@WebCode", ToDBValue(country.WebCode))
					,new SqlParameter("@Region", ToDBValue(country.Region))
					,new SqlParameter("@Continent", ToDBValue(country.Continent))
					,new SqlParameter("@Latitude", ToDBValue(country.Latitude))
					,new SqlParameter("@Longitude", ToDBValue(country.Longitude))
					,new SqlParameter("@SurfaceArea", ToDBValue(country.SurfaceArea))
					,new SqlParameter("@Population", ToDBValue(country.Population))
			};

			return SqlHelper.ExecuteNonQuery(sql, para);
        }		
Ejemplo n.º 3
0
		public int Update(Country country)
        {
            return new CountryDal().Update(country);
        }
Ejemplo n.º 4
0
        public Country Add(Country country)
		{
			string sql ="INSERT INTO Countries (CountryName, LocalName, WebCode, Region, Continent, Latitude, Longitude, SurfaceArea, Population)  output inserted.CountryId VALUES (@CountryName, @LocalName, @WebCode, @Region, @Continent, @Latitude, @Longitude, @SurfaceArea, @Population)";
			SqlParameter[] para = new SqlParameter[]
			{
				new SqlParameter("@CountryName", ToDBValue(country.CountryName)),
				new SqlParameter("@LocalName", ToDBValue(country.LocalName)),
				new SqlParameter("@WebCode", ToDBValue(country.WebCode)),
				new SqlParameter("@Region", ToDBValue(country.Region)),
				new SqlParameter("@Continent", ToDBValue(country.Continent)),
				new SqlParameter("@Latitude", ToDBValue(country.Latitude)),
				new SqlParameter("@Longitude", ToDBValue(country.Longitude)),
				new SqlParameter("@SurfaceArea", ToDBValue(country.SurfaceArea)),
				new SqlParameter("@Population", ToDBValue(country.Population)),
			};
					
			int newId = (int)SqlHelper.ExecuteScalar(sql, para);
			return GetByCountryId(newId);
		}
Ejemplo n.º 5
0
 public Country Add(Country country)
 {
     return new CountryDal().Add(country);
 }