public static SecurityCollection GetSecuritiesByName(string secName, Type securityType)
 {
     SecurityCollection matchingSecs = new SecurityCollection();
     string query = string.Format("SELECT SecurityId, Name FROM {0} WHERE Name LIKE '%{1}%'", securityType.Name, secName);
     DataTable result = DAL.DbInstance.ExecuteSqlQuery(query).Tables[0];
     foreach(DataRow row in result.Rows)
     {
         matchingSecs.Add(new Security()
         {
             Name = (string)row["Name"],
             SecurityId = Convert.ToInt32(row["SecurityId"])
         });
     }
     return matchingSecs;
 }
 public string UpdateSecurity(Json_Tabs json)
 {
     try
     {
         Security newSecurity = json.ConvertToSecurityObject();
         SecurityCollection securities = new SecurityCollection();
         securities.Add(newSecurity);
         securities.PersistCollection(true);
     }
     catch (Exception ex)
     {
         return ex.Message;
     }
     return "true";
 }
        public SecurityCollection ReadSecuritiesFromFile(string filePath)
        {
            SecurityCollection securities = new SecurityCollection();
            string securityName = Path.GetFileNameWithoutExtension(filePath);
            Dictionary<string, List<Dictionary<string, string>>> securitiesData = new Dictionary<string, List<Dictionary<string, string>>>();
            if(File.Exists(filePath))
            {
                InstantiateReader(Path.GetExtension(filePath));
                reader.OpenFile(filePath);
                if (reader.GetType() == typeof(ExcelReader))
                    (reader as ExcelReader).SheetName = securityName;
                securitiesData = reader.ReadFile();
                reader.CloseFile();

                //Convert the complex dictionary to a list of security objects
                Dictionary<string, string> attributeMapping = SecurityAttribute.GetAttributeMappings(GetSecurityObject(securityName).GetType());
                foreach (var securityRow in securitiesData[securityName])
                {
                    securities.Add(FillSecurityObject(GetSecurityObject(securityName), securityRow, attributeMapping));
                }
            }
            
            return securities;
        }