Ejemplo n.º 1
0
 public void Remove(Code code)
 {
     db.Codes.Remove(code);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Transforms a CSV file to IOnEx Codes
        /// </summary>
        /// <param name="url">Url of the CSV file</param>
        /// <returns>List of codes</returns>
        private List<Code> Csv2Codes(string url)
        {
            Code code;
            List<Code> codes = new List<Code>();
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
            StreamReader sr = new StreamReader(resp.GetResponseStream());
            CsvConfiguration config = new CsvConfiguration { Delimiter = ";" };
            CsvReader csvr = new CsvReader(sr, config);
            var rows = csvr.GetRecords<CodeIo>();

            foreach (var r in rows)
            {
                code = new Code
                {
                    AccessCode = r.AccessCode,
                    ExitCode = r.ExitCode
                };
                codes.Add(code);
            }
            return codes;
        }