/// <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); } }
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 }; }
/// <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); }
public void SetUp() { _semesterRepository = Mock.Of<ISemesterRepository>(); _semesterService = new SemesterService(_semesterRepository); _semester = new SemesterItem() { FromDate = DateTime.Now.Date, TrimDate = DateTime.Now.AddDays(120).Date }; }
/// <summary> /// Измененяет данные о семестре. /// </summary> /// <param name="semester">Семестр.</param> public void Update(SemesterItem semester) { if (GetById(semester.Id) == null) { throw new Exception("Семестр не найден."); } _semesterRepository.Update(semester); }
/// <summary> /// Создает семестр. /// </summary> /// <param name="semester">Семестр.</param> /// <returns>Идентификатор созданного семестра.</returns> public int Create(SemesterItem semester) { return _semesterRepository.Create(semester); }
/// <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); } }
public ActionResult Create(SemesterItem semester) { Access.CheckAccess("Semester.Creator"); return RedirectToAction("Index", new { id = _semesterService.Create(semester) }); }
public ActionResult Update(SemesterItem semester) { Access.CheckAccess("Semester.Updater"); _semesterService.Update(semester); return RedirectToAction("Index", new { id = semester.Id }); }
/// <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); }