Класс для хранения данных по дисциплинам.
Beispiel #1
0
        /// <summary>
        /// Создает дисциплину.
        /// </summary>
        /// <param name="discipline">Дисциплина.</param>
        /// <returns>Идентификатор созданной дисциплины.</returns>
        public int Create(DisciplineItem discipline)
        {
            if (string.IsNullOrEmpty(discipline.FullName))
            {
                throw new Exception("Поле 'FullName' не должно быть пустым.");
            }

            if (string.IsNullOrEmpty(discipline.ShortName))
            {
                throw new Exception("Поле 'ShortName' не должно быть пустым.");
            }

            if (string.IsNullOrEmpty(discipline.Mem))
            {
                throw new Exception("Поле 'Mem' не должно быть пустым.");
            }

            return _disciplineRepository.Create(discipline);
        }
Beispiel #2
0
        /// <summary>
        /// Создает новую дисциплину.
        /// </summary>
        /// <param name="discipline">Дисциплина.</param>
        /// <returns>Идентификатор созданной дисциплины.</returns>
        public int Create(DisciplineItem discipline)
        {
            using (var sqlh = new SqlHelper())
            {
                return sqlh.ExecScalar<int>(@"
            insert into Discipline.discipline
            (
            short_name,
            full_name,
            mem
            )
            values
            (
            @ShortName,
            @FullName,
            @Mem
            )

            select scope_identity()", discipline);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Измененяет данные о дисциплине.
        /// </summary>
        /// <param name="discipline">Дисциплина.</param>
        public void Update(DisciplineItem discipline)
        {
            if (string.IsNullOrEmpty(discipline.FullName))
            {
                throw new Exception("Поле 'FullName' не должно быть пустым.");
            }

            if (string.IsNullOrEmpty(discipline.ShortName))
            {
                throw new Exception("Поле 'ShortName' не должно быть пустым.");
            }

            if (string.IsNullOrEmpty(discipline.Mem))
            {
                throw new Exception("Поле 'Mem' не должно быть пустым.");
            }

            if (GetById(discipline.Id) == null)
            {
                throw new Exception("Дисциплина не найдена.");
            }

            _disciplineRepository.Update(discipline);
        }
Beispiel #4
0
        public void SetUp()
        {
            _disciplineRepository = Mock.Of<IDisciplineRepository>();
            _disciplineService = new DisciplineService(_disciplineRepository);

            _discipline = new DisciplineItem()
            {
                Id = 1,
                ShortName = "test",
                FullName = "test_full",
                Mem = "Описание"
            };
        }
Beispiel #5
0
 public ActionResult Create(DisciplineItem discipline)
 {
     Access.CheckAccess("Discipline.Creator");
     return RedirectToAction("List", new { id = _disciplineService.Create(discipline) });
 }
Beispiel #6
0
 public ActionResult Update(DisciplineItem discipline)
 {
     Access.CheckAccess("Discipline.Updater");
     _disciplineService.Update(discipline);
     return RedirectToAction("Index", new { id = discipline.Id });
 }
Beispiel #7
0
        /// <summary>
        /// Интерфейс для создания дисциплины.
        /// </summary>
        /// <returns></returns>
        public ActionResult New()
        {
            Access.CheckAccess("Discipline.Creator");
            var defaultitem = new DisciplineItem();

            return View(defaultitem);
        }
Beispiel #8
0
 /// <summary>
 /// Обновляет данные по дисциплине.
 /// </summary>
 /// <param name="discipline">Дисциплина.</param>
 public void Update(DisciplineItem discipline)
 {
     using (var sqlh = new SqlHelper())
     {
         sqlh.ExecNoQuery(@"
     update Discipline.discipline
     set
     short_name = @ShortName,
     mem = @Mem,
     full_name = @FullName
     where discipline = @Id", discipline);
     }
 }
Beispiel #9
0
        public void SetUp()
        {
            _transactionScope = new TransactionScope();
            _disciplineRepository = new DisciplineRepository();

            _discipline = new DisciplineItem()
            {
                Id = 1,
                FullName = "full_name",
                ShortName = "short_name",
                Mem = "Описание"
            };
            _disciplineNew = new DisciplineItem()
            {
                Id = 2,
                FullName = "full_name_test",
                ShortName = "short_name_test",
                Mem = "Описание2"
            };
        }
Beispiel #10
0
 /// <summary>
 /// Проверяет, эквивалентны ли две дисциплины.
 /// </summary>
 /// <param name="first_discipline"></param>
 /// <param name="second_discipline"></param>
 private void AreEqualDiscipline(DisciplineItem first_discipline, DisciplineItem second_discipline)
 {
     Assert.AreEqual(first_discipline.Id, second_discipline.Id);
     Assert.AreEqual(first_discipline.FullName, second_discipline.FullName);
     Assert.AreEqual(first_discipline.ShortName, second_discipline.ShortName);
     Assert.AreEqual(first_discipline.Mem, second_discipline.Mem);
 }