Класс для хранения данных по аудиториям.
示例#1
0
        /// <summary>
        /// Создает новую аудиторию.
        /// </summary>
        /// <param name="auditory">Аудитория.</param>
        /// <returns>Идентификатор созданной аудитории.</returns>
        public int Create(AuditoryItem auditory)
        {
            using (var sqlh = new SqlHelper())
            {
                return sqlh.ExecScalar<int>(@"
            insert into Auditory.auditory
            (
            number,
            full_name,
            memo,
            level,
            capacity
            )
            values
            (
            @Number,
            @FullName,
            @Memo,
            @Level,
            @Capacity
            )

            select scope_identity()", auditory);
            }
        }
示例#2
0
 /// <summary>
 /// Создает аудиторию.
 /// </summary>
 /// <param name="auditory">Аудитория.</param>
 /// <returns>Идентификаторо созданной аудитории.</returns>
 public int Create(AuditoryItem auditory)
 {
     if(string.IsNullOrEmpty(auditory.FullName))
     {
         throw new Exception("Поле 'FullName' не должно быть пустым.");
     }
     if (string.IsNullOrEmpty(auditory.Memo))
     {
         throw new Exception("Поле 'Memo' не должно быть пустым.");
     }
     return _auditoryRepository.Create(auditory);
 }
示例#3
0
        public void SetUp()
        {
            _transactionScope = new TransactionScope();
            _auditoryRepository = new AuditoryRepository();

            _auditory = new AuditoryItem()
            {
                Number = 1,
                FullName = "Аудитория информатики",
                Memo = "В аудитории присутствует 16 компьютеров, проектор, интерактивная доска",
                Level = 3,
                Capacity = 15
            };
            _auditoryNew = new AuditoryItem()
            {
                Number = 2,
                FullName = "Аудитория экономики",
                Memo = "В аудитории присутствует 5 компьютеров, проектор, интерактивная доска и много учебной литературы",
                Level = 2,
                Capacity = 20
            };
        }
示例#4
0
 /// <summary>
 /// Проверяет эквивалентны ли две аудитории.
 /// </summary>
 /// <param name="first_auditory"></param>
 /// <param name="second_auditory"></param>
 private void AreEqualAuditory(AuditoryItem first_auditory, AuditoryItem second_auditory)
 {
     Assert.AreEqual(first_auditory.Id, second_auditory.Id);
     Assert.AreEqual(first_auditory.Number, second_auditory.Number);
     Assert.AreEqual(first_auditory.FullName, second_auditory.FullName);
     Assert.AreEqual(first_auditory.Memo, second_auditory.Memo);
     Assert.AreEqual(first_auditory.Level, second_auditory.Level);
     Assert.AreEqual(first_auditory.Capacity, second_auditory.Capacity);
 }
示例#5
0
 /// <summary>
 /// Измененяет данные об аудитории.
 /// </summary>
 /// <param name="auditory">Аудитория.</param>
 public void Update(AuditoryItem auditory)
 {
     if (string.IsNullOrEmpty(auditory.FullName))
     {
         throw new Exception("Поле 'FullName' не должно быть пустым.");
     }
     if (string.IsNullOrEmpty(auditory.Memo))
     {
         throw new Exception("Поле 'Memo' не должно быть пустым.");
     }
     if (GetById(auditory.Id) == null)
     {
         throw new Exception("Аудитория не найдена.");
     }
     _auditoryRepository.Update(auditory);
 }
示例#6
0
 /// <summary>
 /// Обновляет данные по аудитории.
 /// </summary>
 /// <param name="auditory">Аудитория.</param>
 public void Update(AuditoryItem auditory)
 {
     using (var sqlh = new SqlHelper())
     {
         sqlh.ExecNoQuery(@"
     update Auditory.auditory
     set
     number = @Number,
     full_name = @FullName,
     memo = @Memo,
     level = @Level,
     capacity = @Capacity
     where auditory = @Id", auditory);
     }
 }
示例#7
0
        public void SetUp()
        {
            _auditoryRepository = Mock.Of<IAuditoryRepository>();
            _auditoryService = new AuditoryService(_auditoryRepository);

            _auditory = new AuditoryItem()
            {
                Id = 1,
                Number = 1,
                FullName = "Auditory 1",
                Memo = "New auditory 1",
                Level = 1,
                Capacity = 1
            };
        }