/// <summary> /// Создает кафедру. /// </summary> /// <param name="cathedra">Кафедра.</param> /// <returns>Идентификатор созданной кафедры.</returns> public int Create(CathedraItem cathedra) { if (string.IsNullOrEmpty(cathedra.FullName)) { throw new Exception("Поле 'FullName' не должно быть пустым."); } if (string.IsNullOrEmpty(cathedra.ShortName)) { throw new Exception("Поле 'ShortName' не должно быть пустым."); } return _cathedraRepository.Create(cathedra); }
/// <summary> /// Создает новую кафедру. /// </summary> /// <param name="cathedra">Кафедра.</param> /// <returns>Идентификатор созданной кафедры.</returns> public int Create(CathedraItem cathedra) { using (var sqlh = new SqlHelper()) { return sqlh.ExecScalar<int>(@" insert into Cathedra.cathedra ( full_name, short_name, faculty ) values ( @FullName, @ShortName, @FacultyId ) select scope_identity()", cathedra); } }
public void SetUp() { _transactionScope = new TransactionScope(); _facultyRepository = new FacultyRepository(); _cathedraRepository = new CathedraRepository(); _faculty = new FacultyItem() { FullName = "Информационный", ShortName = "И", }; _facultyNew = new FacultyItem() { FullName = "Экономический", ShortName = "Э", }; _cathedra = new CathedraItem() { FullName = "Информациионных систем и технологий", ShortName = "ИСиТ", FacultyId = _facultyRepository.Create(_faculty) }; _cathedraNew = new CathedraItem() { FullName = "Экономики и управления", ShortName = "ЭиЭ", FacultyId = _facultyRepository.Create(_facultyNew) }; }
/// <summary> /// Проверяет эквивалентны ли две кафедры. /// </summary> /// <param name="first_cathedra"></param> /// <param name="second_cathedra"></param> private void AreEqualCathedra(CathedraItem first_cathedra, CathedraItem second_cathedra) { Assert.AreEqual(first_cathedra.Id, second_cathedra.Id); Assert.AreEqual(first_cathedra.FullName, second_cathedra.FullName); Assert.AreEqual(first_cathedra.ShortName, second_cathedra.ShortName); Assert.AreEqual(first_cathedra.FacultyId, second_cathedra.FacultyId); }
/// <summary> /// Обновляет данные у кафедры. /// </summary> /// <param name="cathedra">Кафедра.</param> public void Update(CathedraItem cathedra) { using (var sqlh = new SqlHelper()) { sqlh.ExecNoQuery(@" update Cathedra.cathedra set full_name = @FullName, short_name = @ShortName, faculty = @FacultyId where cathedra = @Id", cathedra); } }
public void SetUp() { _cathedraRepository = Mock.Of<ICathedraRepository>(); _cathedraService = new CathedraService(_cathedraRepository); _cathedra = new CathedraItem() { FullName = "Информациионных систем и технологий", ShortName = "ИСиТ", FacultyId = 1 }; }
public void SetUp() { _transactionScope = new TransactionScope(); _lecturerRepository = new LecturerRepository(); _cathedraRepository = new CathedraRepository(); _facultyRepository = new FacultyRepository(); _personRepository = new PersonRepository(); _faculty = new FacultyItem() { FullName = "Информационный", ShortName = "И", }; _cathedra = new CathedraItem() { FullName = "Информациионных систем и технологий", ShortName = "ИСиТ", FacultyId = _facultyRepository.Create(_faculty) }; _person = new PersonItem() { Birthday = DateTime.Now.AddDays(2).Date, FatherName = "Сидорович", FirstName = "Сидор", LastName = "Сидоров", }; _lecturer = new LecturerItem() { CathedraId = _cathedraRepository.Create(_cathedra), Birthday = _person.Birthday, FatherName = _person.FatherName, FirstName = _person.FirstName, Id = _personRepository.Create(_person), LastName = _person.LastName, }; _personNew = new PersonItem() { Birthday = DateTime.Now.AddDays(3).Date, FatherName = "Петрович", FirstName = "Петр", LastName = "Петров", }; _lecturerNew = new LecturerItem() { CathedraId = _cathedraRepository.Create(_cathedra), Birthday = _personNew.Birthday, FatherName = _personNew.FatherName, FirstName = _personNew.FirstName, Id = _personRepository.Create(_person), LastName = _personNew.LastName }; }
public void SetUp() { _transactionScope = new TransactionScope(); _specialtyRepository = new SpecialtyRepository(); _specialtyDetailRepository = new SpecialtyDetailRepository(); _cathedraRepository = new CathedraRepository(); _facultyRepository = new FacultyRepository(); _faculty = new FacultyItem() { FullName = "Информационный", ShortName = "И", }; _cathedra = new CathedraItem() { FullName = "Информациионных систем и технологий", ShortName = "ИСиТ", FacultyId = _facultyRepository.Create(_faculty) }; _specialty = new SpecialtyItem() { FullName = "Программное обеспечение вычислительной техники и автоматизированных систем", ShortName = "Ифн", Code = "230105", CathedraId = _cathedraRepository.Create(_cathedra) }; _specialtyNew = new SpecialtyItem() { FullName = "Экономика и технология производства", ShortName = "ЭТП", Code = "230221", CathedraId = _cathedraRepository.Create(_cathedra) }; _specialtyDetail = new SpecialtyDetailItem() { ActualDate = new DateTime(2015,01,01), SpecialtyId = _specialtyRepository.Create(_specialty), SemestrCount = 1, TrainingPeriod = 1, Qualification = Qualification.Bachelor, FormStudy = FormStudy.Distance, PaySpace = 15, LowcostSpace = 4, }; _specialtyDetailNew = new SpecialtyDetailItem() { ActualDate = new DateTime(2015,01,02), SpecialtyId = _specialtyRepository.Create(_specialtyNew), SemestrCount = 2, TrainingPeriod = 2, Qualification = Qualification.Master, FormStudy = FormStudy.Fulltime, PaySpace = 30, LowcostSpace = 6, }; }
public ActionResult Create(CathedraItem cathedra) { Access.CheckAccess("Cathedra.Creator"); return RedirectToAction("Index", new { id = _cathedraService.Create(cathedra) }); }
public ActionResult Update(CathedraItem cathedra) { Access.CheckAccess("Cathedra.Updater"); _cathedraService.Update(cathedra); return RedirectToAction("Index", new { id = cathedra.Id }); }
/// <summary> /// Интерфейс для создания кафедры. /// </summary> /// <returns></returns> public ActionResult New() { Access.CheckAccess("Cathedra.Creator"); var default_item = new CathedraItem { FullName = "", ShortName = "" }; return View(default_item); }
public void SetUp() { _transactionScope = new TransactionScope(); _cathedraRepository = new CathedraRepository(); _specialtyRepository = new SpecialtyRepository(); _facultyIdRepository = new FacultyRepository(); _faculty = new FacultyItem() { FullName = "Информационный", ShortName = "И", }; _cathedra = new CathedraItem() { FullName = "Информациионных систем и технологий", ShortName = "ИСиТ", FacultyId = _facultyIdRepository.Create(_faculty) }; _cathedraNew = new CathedraItem() { FullName = "Экономика и организация производлства", ShortName = "ЭиОП", FacultyId = _facultyIdRepository.Create(_faculty) }; _specialty = new SpecialtyItem() { FullName = "Программное обеспечение вычислительной техники и автоматизированных систем", ShortName = "Ифн", Code = "230105", CathedraId = _cathedraRepository.Create(_cathedra) }; _specialtyNew = new SpecialtyItem() { FullName = "Сисадмин", ShortName = "Сис", Code = "123456", CathedraId = _cathedraRepository.Create(_cathedraNew) }; }
/// <summary> /// Измененяет данные о кафедре. /// </summary> /// <param name="cathedra">Кафедра.</param> public void Update(CathedraItem cathedra) { if (string.IsNullOrEmpty(cathedra.FullName)) { throw new Exception("Поле 'FullName' не должно быть пустым."); } if (string.IsNullOrEmpty(cathedra.ShortName)) { throw new Exception("Поле 'ShortName' не должно быть пустым."); } if (GetById(cathedra.Id) == null) { throw new Exception("Кафедра не найдена."); } _cathedraRepository.Update(cathedra); }