Класс для хранения данных о семестре.
示例#1
0
        /// <summary>
        /// Создает новый семестр.
        /// </summary>
        /// <param name="semester">Семестр.</param>
        /// <returns>Идентификатор созданного семестра.</returns>
        public int Create(SemesterItem semester)
        {
            using (var sqlh = new SqlHelper())
            {
                return sqlh.ExecScalar<int>(@"
            insert into Calendar.semester
            (
            from_date,
            trim_date
            )
            values
            (
            @FromDate,
            @TrimDate
            )

            select scope_identity()", semester);
            }
        }
示例#2
0
        public void SetUp()
        {
            _transactionScope = new TransactionScope();
            _semesterRepository = new SemesterRepository();

            _semester = new SemesterItem()
            {
                FromDate = DateTime.Now.Date,
                TrimDate = DateTime.Now.AddDays(120).Date
            };
            _semesterNew = new SemesterItem()
            {
                FromDate = DateTime.Now.Date,
                TrimDate = DateTime.Now.AddDays(121).Date
            };
        }
示例#3
0
 /// <summary>
 /// Проверяет еквивалентны ли два семестра.
 /// </summary>
 /// <param name="first_semester">Первый семестр.</param>
 /// <param name="second_semester">Второй семестр.</param>
 private void AreEqualSemesters(SemesterItem first_semester, SemesterItem second_semester)
 {
     Assert.AreEqual(first_semester.Id, second_semester.Id);
     Assert.AreEqual(first_semester.FromDate, second_semester.FromDate);
     Assert.AreEqual(first_semester.TrimDate, second_semester.TrimDate);
 }
示例#4
0
        public void SetUp()
        {
            _semesterRepository = Mock.Of<ISemesterRepository>();
            _semesterService = new SemesterService(_semesterRepository);

            _semester = new SemesterItem()
            {
                FromDate = DateTime.Now.Date,
                TrimDate = DateTime.Now.AddDays(120).Date
            };
        }
示例#5
0
        /// <summary>
        /// Измененяет данные о семестре.
        /// </summary>
        /// <param name="semester">Семестр.</param>
        public void Update(SemesterItem semester)
        {
            if (GetById(semester.Id) == null)
            {
                throw new Exception("Семестр не найден.");
            }

            _semesterRepository.Update(semester);
        }
示例#6
0
 /// <summary>
 /// Создает семестр.
 /// </summary>
 /// <param name="semester">Семестр.</param>
 /// <returns>Идентификатор созданного семестра.</returns>
 public int Create(SemesterItem semester)
 {
     return _semesterRepository.Create(semester);
 }
示例#7
0
 /// <summary>
 /// Обновляет данные по семестру.
 /// </summary>
 /// <param name="semester">Семестр.</param>
 public void Update(SemesterItem semester)
 {
     using (var sqlh = new SqlHelper())
     {
         sqlh.ExecNoQuery(@"
     update Calendar.semester
     set
     from_date = @FromDate,
     trim_date = @TrimDate
     where semester = @Id", semester);
     }
 }
示例#8
0
 public ActionResult Create(SemesterItem semester)
 {
     Access.CheckAccess("Semester.Creator");
     return RedirectToAction("Index", new { id = _semesterService.Create(semester) });
 }
示例#9
0
 public ActionResult Update(SemesterItem semester)
 {
     Access.CheckAccess("Semester.Updater");
     _semesterService.Update(semester);
     return RedirectToAction("Index", new { id = semester.Id });
 }
示例#10
0
 /// <summary>
 /// Интерфейс для создания семестра.
 /// </summary>
 /// <returns></returns>
 public ActionResult New()
 {
     Access.CheckAccess("Semester.Creator");
     var default_item = new SemesterItem
     {
         FromDate = DateTime.Now,
         TrimDate = DateTime.Now
     };
     return View(default_item);
 }