Пример #1
0
        public void AddRange(IEnumerable <Student> students)
        {
            foreach (var student in students)
            {
                SetStudentSchoolProperties(student);

                student.CreatedAt = DateTime.Today;
                student.IsDeleted = false;
            }

            ValidateStudentRange(students);

            _studentRepository.AddRange(students);
        }
Пример #2
0
        public void TestAddRangeCase()
        {
            var rep = new IStudentRepository();

            try
            {
                rep.AddRange(new List <Student> {
                    new Student()
                    {
                        FirstName = "Дмитрий", MiddleName = "Андреевич", LastName = "Kevlev", GroupNumber = "11-508", Email = "*****@*****.**"
                    }
                });
            }
            catch (Exception ex)
            {
                StringAssert.Contains(ex.Message, "Error in open session");
            }
        }
Пример #3
0
        public static void parse(string filename)
        {
            FileInfo fileInfo = new FileInfo(filename);

            NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
            if (fileInfo.Exists)
            {
                if (fileInfo.Name.EndsWith(".xml"))
                {
                    XDocument xdoc = XDocument.Load(filename);

                    List <Student> studentList = xdoc.Descendants("Student").Select(d =>
                                                                                    new Student
                    {
                        FirstName   = d.Element("FirstName").Value,
                        MiddleName  = d.Element("MiddleName").Value,
                        LastName    = d.Element("LastName").Value,
                        GroupNumber = d.Element("GroupNumber").Value,
                        Email       = d.Element("Email").Value
                    }).ToList();

                    StudentRepository st = new IStudentRepository();
                    //st.DeleteAll();
                    st.AddRange(studentList);
                }
                else
                {
                    MessageBox.Show("No correct name of file");
                    log.Error("No correct name of file");
                }
            }
            else
            {
                MessageBox.Show("File not found");
                log.Error("File not found");
            }
        }