public static EnemyItemIDLink DetailsDOtoPO(EnemyItemDO from) { EnemyItemIDLink to = new EnemyItemIDLink(); to.LinkID = from.LinkID; to.EnemyID = from.EnemyID; to.ItemID = from.ItemID; return(to); }
public static EnemyItemDO DetailsPOtoDO(EnemyItemIDLink from) { EnemyItemDO to = new EnemyItemDO(); to.LinkID = from.LinkID; to.EnemyID = from.EnemyID; to.ItemID = from.ItemID; return(to); }
//mapper to map a single EnemyItem link form the server to an EnemyItemDO object //this item shows what items an enemy drops. //stores the EnemyID, the ItemID, and the ID of the link in the database public static EnemyItemDO MapSingleEnemyLink(SqlDataReader from) { EnemyItemDO to = new EnemyItemDO(); to.LinkID = (int)from["ID"]; to.EnemyID = (int)from["EnemyID"]; to.ItemID = (int)from["ItemID"]; return(to); }
public static List <EnemyItemDO> DetailsPOtoDO(List <EnemyItemIDLink> from) { List <EnemyItemDO> to = new List <EnemyItemDO>(); foreach (EnemyItemIDLink enemy in from) { EnemyItemDO temp = new EnemyItemDO(); temp.LinkID = enemy.LinkID; temp.EnemyID = enemy.EnemyID; temp.ItemID = enemy.ItemID; to.Add(temp); } return(to); }
public List <EnemyItemDO> ViewByEnemyID(int id) { List <EnemyItemDO> enemy = new List <EnemyItemDO>(); try { using (SqlConnection sqlConnection = new SqlConnection(connectionString)) using (SqlCommand PullEnemyDrops = new SqlCommand("ENEMYDROPS_BY_ENEMYID", sqlConnection)) { PullEnemyDrops.CommandType = CommandType.StoredProcedure; PullEnemyDrops.Parameters.AddWithValue("EnemyID", id); sqlConnection.Open(); using (SqlDataReader reader = PullEnemyDrops.ExecuteReader()) { while (reader.Read()) { EnemyItemDO temp = Mappers.Mapper.MapSingleEnemyLink(reader); enemy.Add(temp); } } } } catch (SqlException sqlEx) { Logger.LogSqlException(sqlEx); sqlEx.Data["Logged"] = true; throw sqlEx; } catch (Exception ex) { Logger.LogException(ex); ex.Data["Logged"] = true; throw ex; } return(enemy); }
public void CreateEnemyDetails(EnemyItemDO enemyDetails) { try { using (SqlConnection sqlConnection = new SqlConnection(connectionString)) using (SqlCommand CreateEnemyDetails = new SqlCommand("ENEMYDROPS_CREATE", sqlConnection)) { CreateEnemyDetails.CommandType = CommandType.StoredProcedure; CreateEnemyDetails.Parameters.AddWithValue("EnemyID", enemyDetails.EnemyID); CreateEnemyDetails.Parameters.AddWithValue("ItemID", enemyDetails.ItemID); sqlConnection.Open(); CreateEnemyDetails.ExecuteNonQuery(); } } catch (SqlException sqlEx) { Logger.LogSqlException(sqlEx); sqlEx.Data["Logged"] = true; throw sqlEx; } }
public void UpdateEnemyLink(EnemyItemDO enemyLink) { try { using (SqlConnection sqlConnection = new SqlConnection(connectionString)) using (SqlCommand UpdateEnemyLink = new SqlCommand("ENEMYDROPS_UPDATE", sqlConnection)) { UpdateEnemyLink.CommandType = CommandType.StoredProcedure; UpdateEnemyLink.Parameters.AddWithValue("LinkID", enemyLink.LinkID); UpdateEnemyLink.Parameters.AddWithValue("EnemyID", enemyLink.EnemyID); UpdateEnemyLink.Parameters.AddWithValue("ItemID", enemyLink.ItemID); sqlConnection.Open(); UpdateEnemyLink.ExecuteNonQuery(); } } catch (SqlException sqlEx) { Logger.LogSqlException(sqlEx); sqlEx.Data["Logged"] = true; throw sqlEx; } }
public List <EnemyItemDO> ViewAllLinks() { List <EnemyItemDO> fullLinkList = new List <EnemyItemDO>(); try { using (SqlConnection sqlConnection = new SqlConnection(connectionString)) using (SqlCommand pullAllLinks = new SqlCommand("ENEMYDROPS_VIEW_ALL", sqlConnection)) { pullAllLinks.CommandType = CommandType.StoredProcedure; sqlConnection.Open(); using (SqlDataReader reader = pullAllLinks.ExecuteReader()) { while (reader.Read()) { EnemyItemDO temp = Mappers.Mapper.MapSingleEnemyLink(reader); fullLinkList.Add(temp); } } } } catch (SqlException sqlEx) { Logger.LogSqlException(sqlEx); sqlEx.Data["Logged"] = true; throw sqlEx; } catch (Exception ex) { Logger.LogException(ex); ex.Data["Logged"] = true; throw ex; } return(fullLinkList); }