private static SqlParameter[] CreateSqlParameter(ContactsBackup model) { return(new SqlParameter[] { new SqlParameter("@Id", model.Id), new SqlParameter("@PhoneNumber", model.PhoneNumber), new SqlParameter("@ComPort", model.ComPort), new SqlParameter("@CreatedDate", model.CreatedDate), new SqlParameter("@SimNumber", model.SimNumber), }); }
public static ContactsBackup UpdateItem(ContactsBackup model) { Int32 result = 0; using (var reader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "ContactsBackup_Update", CreateSqlParameter(model))) { while (reader.Read()) { result = (Int32)reader[0]; } } return(GetItemByID(result)); }
public static ContactsBackup GetItemByID(Int32 id) { ContactsBackup item = new ContactsBackup(); var sqlParams = new SqlParameter[1]; sqlParams[0] = new SqlParameter("@Id", id); using (var reader = SqlHelper.ExecuteReader("ContactsBackup_GetByID", sqlParams)) { while (reader.Read()) { item = GetItemFromReader(reader); } } return(item); }
private static ContactsBackup GetItemFromReader(IDataReader dataReader) { ContactsBackup objItem = new ContactsBackup(); objItem.Id = SqlHelper.GetInt(dataReader, "Id"); objItem.PhoneNumber = SqlHelper.GetString(dataReader, "PhoneNumber"); objItem.ComPort = SqlHelper.GetString(dataReader, "ComPort"); objItem.CreatedDate = SqlHelper.GetDateTime(dataReader, "CreatedDate"); objItem.SimNumber = SqlHelper.GetString(dataReader, "SimNumber"); return(objItem); }
public static ContactsBackupCollection GetSimPort() { ContactsBackupCollection collection = new ContactsBackupCollection(); using (var reader = SqlHelper.ExecuteReader("ContactsBackup_GetComPort", null)) { while (reader.Read()) { ContactsBackup obj = new ContactsBackup(); obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }