public Boolean DeleteSecurity(Security securityObject) { command = new SqlCommand(); command.Connection = conn; command.CommandType = CommandType.StoredProcedure; command.CommandText = "DeleteSecurity"; command.Parameters.AddWithValue("@securityTypeId", SqlDbType.VarChar).Value = securityObject.GetType(); command.Parameters.AddWithValue("@securityId", SqlDbType.VarChar).Value = securityObject.SecurityId; command.ExecuteNonQuery(); return true; }
Security FillSecurityObject(Security security, Dictionary<string, string> securityRow, Dictionary<string, string> attributeMapping) { foreach (var key in securityRow.Keys) { if (attributeMapping.Keys.Contains(key) && securityRow[key] != string.Empty) { Type propertyType = security.GetType().GetProperty(attributeMapping[key]).PropertyType; //TODO: Find a way to convert the date strings from excel into SqlDateTime properly. Below statement is temporarily placed to avoid using the Date attributes. if (propertyType == typeof(SqlDateTime)) continue; security.GetType().GetProperty(attributeMapping[key]).SetValue( security, Convert.ChangeType(securityRow[key], propertyType), null ); } } return security; }
//public Security this[int index] { get { return securitiesList[index]; } } public void Add(Security security) { SecuritiesList.Add(security); }