Example #1
0
 /// <summary>
 /// Проверяет эквивалентны ли два преподавателя.
 /// </summary>
 /// <param name="firstLecturer">Первый преподаватель.</param>
 /// <param name="secondLecturer">Второй преподаватель.</param>
 private void AreEqualPerson(LecturerItem firstLecturer, LecturerItem secondLecturer)
 {
     Assert.AreEqual(firstLecturer.Id, secondLecturer.Id);
     Assert.AreEqual(firstLecturer.LastName, secondLecturer.LastName);
     Assert.AreEqual(firstLecturer.FirstName, secondLecturer.FirstName);
     Assert.AreEqual(firstLecturer.FatherName, secondLecturer.FatherName);
     Assert.AreEqual(firstLecturer.Birthday, secondLecturer.Birthday);
     Assert.AreEqual(firstLecturer.CathedraId, secondLecturer.CathedraId);
 }
Example #2
0
        public void SetUp()
        {
            _transactionScope   = new TransactionScope();
            _lecturerRepository = new LecturerRepository();
            _cathedraRepository = new CathedraRepository();
            _facultyRepository  = new FacultyRepository();
            _personRepository   = new PersonRepository();

            _faculty = new FacultyItem()
            {
                FullName  = "Информационный",
                ShortName = "И",
            };

            _cathedra = new CathedraItem()
            {
                FullName  = "Информациионных систем и технологий",
                ShortName = "ИСиТ",
                FacultyId = _facultyRepository.Create(_faculty)
            };

            _person = new PersonItem()
            {
                Birthday   = DateTime.Now.AddDays(2).Date,
                FatherName = "Сидорович",
                FirstName  = "Сидор",
                LastName   = "Сидоров",
            };

            _lecturer = new LecturerItem()
            {
                CathedraId = _cathedraRepository.Create(_cathedra),
                Birthday   = _person.Birthday,
                FatherName = _person.FatherName,
                FirstName  = _person.FirstName,
                Id         = _personRepository.Create(_person),
                LastName   = _person.LastName,
            };

            _personNew = new PersonItem()
            {
                Birthday   = DateTime.Now.AddDays(3).Date,
                FatherName = "Петрович",
                FirstName  = "Петр",
                LastName   = "Петров",
            };
            _lecturerNew = new LecturerItem()
            {
                CathedraId = _cathedraRepository.Create(_cathedra),
                Birthday   = _personNew.Birthday,
                FatherName = _personNew.FatherName,
                FirstName  = _personNew.FirstName,
                Id         = _personRepository.Create(_person),
                LastName   = _personNew.LastName
            };
        }
        private IList <LecturerItem> ConvertToLecturerItem(IDictionary <int, Lecturer> lecturers)
        {
            IList <LecturerItem> lectureHallItems = new List <LecturerItem>();

            foreach (Lecturer lecturer in lecturers.Values)
            {
                LecturerItem lecturerItem = new LecturerItem()
                {
                    Id      = lecturer.Id,
                    Title   = lecturer.Title,
                    Name    = lecturer.Name,
                    Surname = lecturer.Surname
                };

                lectureHallItems.Add(lecturerItem);
            }

            return(lectureHallItems);
        }
Example #4
0
        /// <summary>
        /// Удаляет преподавателя.
        /// </summary>
        /// <param name="id">Идентификатор.</param>
        public void Delete(LecturerItem lecturer)
        {
            using (SqlHelper sqlh = new SqlHelper())
            {
                sqlh.ExecNoQuery(@"
insert into Person.lecturer
(
	event_date,
	act,
	person,
	cathedra
)
values
(
	getdate(),
	-1,
	@Id,
	@CathedraId
)
select @Id", lecturer);
            }
        }
Example #5
0
        /// <summary>
        /// Создает нового преподавателя.
        /// </summary>
        /// <param name="lecturer">Преподаватель.</param>
        /// <returns>Идентификатор созданного преподавателя.</returns>
        public int Create(LecturerItem lecturer)         // Изменить
        {
            using (var sqlh = new SqlHelper())
            {
                return(sqlh.ExecScalar <int>(@"
insert into Person.lecturer
(
	event_date,
	act,
	person,
	cathedra
)
values
(
	getdate(),
	1,
	@Id,
	@CathedraId
)
select @Id", lecturer));
            }
        }