public City ToModel(SqlDataReader reader) { City city = new City(); city.CityId = (int)ToModelValue(reader,"CityId"); city.CityName = (string)ToModelValue(reader,"CityName"); city.StateId = (int)ToModelValue(reader,"StateId"); city.CountryId = (int)ToModelValue(reader,"CountryId"); city.Latitude = (double)ToModelValue(reader,"Latitude"); city.Longitude = (double)ToModelValue(reader,"Longitude"); city.Temperature = (decimal)ToModelValue(reader,"Temperature"); return city; }
public int Update(City city) { string sql = "UPDATE Cities SET CityName=@CityName,StateId=@StateId,CountryId=@CountryId,Latitude=@Latitude,Longitude=@Longitude,Temperature=@Temperature WHERE CityId = @CityId"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@CityId", city.CityId) ,new SqlParameter("@CityName", ToDBValue(city.CityName)) ,new SqlParameter("@StateId", ToDBValue(city.StateId)) ,new SqlParameter("@CountryId", ToDBValue(city.CountryId)) ,new SqlParameter("@Latitude", ToDBValue(city.Latitude)) ,new SqlParameter("@Longitude", ToDBValue(city.Longitude)) ,new SqlParameter("@Temperature", ToDBValue(city.Temperature)) }; return SqlHelper.ExecuteNonQuery(sql, para); }
public City Add(City city) { string sql ="INSERT INTO Cities (CityName, StateId, CountryId, Latitude, Longitude, Temperature) output inserted.CityId VALUES (@CityName, @StateId, @CountryId, @Latitude, @Longitude, @Temperature)"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@CityName", ToDBValue(city.CityName)), new SqlParameter("@StateId", ToDBValue(city.StateId)), new SqlParameter("@CountryId", ToDBValue(city.CountryId)), new SqlParameter("@Latitude", ToDBValue(city.Latitude)), new SqlParameter("@Longitude", ToDBValue(city.Longitude)), new SqlParameter("@Temperature", ToDBValue(city.Temperature)), }; int newId = (int)SqlHelper.ExecuteScalar(sql, para); return GetByCityId(newId); }
public int Put(int id, City city) { return _cityBll.Update(city); }
public int Update(City city) { return new CityDal().Update(city); }
public City Add(City city) { return new CityDal().Add(city); }