Beispiel #1
0
		public State ToModel(SqlDataReader reader)
		{
			State state = new State();

			state.StateId = (int)ToModelValue(reader,"StateId");
			state.StateName = (string)ToModelValue(reader,"StateName");
			state.CountryId = (int)ToModelValue(reader,"CountryId");
			state.Latitude = (double)ToModelValue(reader,"Latitude");
			state.Longitude = (double)ToModelValue(reader,"Longitude");
			return state;
		}
Beispiel #2
0
        public int Update(State state)
        {
            string sql = "UPDATE States SET StateName=@StateName,CountryId=@CountryId,Latitude=@Latitude,Longitude=@Longitude WHERE StateId = @StateId"; 
            
			SqlParameter[] para = new SqlParameter[]
			{
				new SqlParameter("@StateId", state.StateId)
					,new SqlParameter("@StateName", ToDBValue(state.StateName))
					,new SqlParameter("@CountryId", ToDBValue(state.CountryId))
					,new SqlParameter("@Latitude", ToDBValue(state.Latitude))
					,new SqlParameter("@Longitude", ToDBValue(state.Longitude))
			};

			return SqlHelper.ExecuteNonQuery(sql, para);
        }		
Beispiel #3
0
		public int Update(State state)
        {
            return new StateDal().Update(state);
        }
Beispiel #4
0
        public State Add(State state)
		{
			string sql ="INSERT INTO States (StateName, CountryId, Latitude, Longitude)  output inserted.StateId VALUES (@StateName, @CountryId, @Latitude, @Longitude)";
			SqlParameter[] para = new SqlParameter[]
			{
				new SqlParameter("@StateName", ToDBValue(state.StateName)),
				new SqlParameter("@CountryId", ToDBValue(state.CountryId)),
				new SqlParameter("@Latitude", ToDBValue(state.Latitude)),
				new SqlParameter("@Longitude", ToDBValue(state.Longitude)),
			};
					
			int newId = (int)SqlHelper.ExecuteScalar(sql, para);
			return GetByStateId(newId);
		}
Beispiel #5
0
 public State Add(State state)
 {
     return new StateDal().Add(state);
 }