public static void LoadData() { if (TypeDAL.getList().Count == 0) { TypeDAL.LoadData(); } //string fileName = @"input.csv"; string fileName = AppDomain.CurrentDomain.BaseDirectory + @"..\DAL\source\input.csv"; //string fileName = "c:/Users/brayan-pc/documents/visual studio 2017/Projects/Students/DAL/source/input.csv"; try { int contador = 0; foreach (var line in File.ReadLines(fileName).Skip(1)) { contador++; var data = line.Split(';'); TypeBO type = TypeDAL.findByName(data[0]); StudentBO student_new = new StudentBO(); student_new.Type = type; student_new.Id = contador; student_new.Name = data[1]; student_new.Gender = char.Parse(data[2]); student_new.SetTime(data[3]); StudentDAL.students.Add(student_new); } } catch (Exception) { throw; } //return myList; }
public static bool Create(int typeId, string name, char gender) { bool result = false; try { TypeBO type = TypeDAL.findById(typeId); StudentBO student_new = new StudentBO(); student_new.Type = type; student_new.Id = StudentDAL.getList().OrderByDescending(o => o.Id).First().Id + 1; student_new.Name = name; student_new.Gender = gender; student_new.SetTime(); StudentDAL.students.Add(student_new); result = true; } catch (Exception) { result = false; throw; } return(result); }