示例#1
0
        public static bool Edit(int id, int typeId, string name, char gender)
        {
            bool result = false;

            try
            {
                foreach (var item in StudentDAL.students)
                {
                    if (item.Id == id)
                    {
                        TypeBO type = TypeDAL.findById(typeId);
                        item.Type   = type;
                        item.Name   = name;
                        item.Gender = gender;
                        item.SetTime();
                    }
                }
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }
示例#2
0
        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;
        }
示例#3
0
        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);
        }
示例#4
0
        public static void LoadData2()
        {
            TypeBO type = new TypeBO();

            if (TypeDAL.getList().Count == 0)
            {
                TypeDAL.LoadData();
            }

            type = TypeDAL.findById(2);

            StudentBO student = new StudentBO();

            student.Id     = 1;
            student.Name   = "Jose";
            student.Gender = 'M';
            student.Type   = type;
            student.Time   = DateTime.Now.ToString();

            StudentDAL.students.Add(student);

            StudentBO student_2 = new StudentBO();

            student_2.Id     = 2;
            student_2.Name   = "Maria";
            student_2.Gender = 'F';
            student_2.Type   = type;
            student_2.Time   = DateTime.Now.ToString();

            StudentDAL.students.Add(student_2);

            StudentBO student_3 = new StudentBO();

            student_3.Id     = 3;
            student_3.Name   = "Jorge";
            student_3.Gender = 'M';
            student_3.Type   = type;
            student_3.Time   = DateTime.Now.ToString();

            StudentDAL.students.Add(student_3);
            //return myList;
        }