/// <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); } }
/// <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); }
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 }; }
/// <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); }
/// <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); }
/// <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); } }
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 }; }