Класс для хранения данных о сущности групп.
Ejemplo n.º 1
0
        /// <summary>
        /// Создает новую группу.
        /// </summary>
        /// <param name="team">Группа.</param>
        /// <returns>Идентификатор созданной группы.</returns>
        public int Create(TeamItem team)
        {
            if (string.IsNullOrWhiteSpace(team.Name))
            {
                throw new Exception("Поле 'Name' не должно быть пустым.");
            }

            return _teamRepository.Create(team);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Создает новую группу.
        /// </summary>
        /// <param name="team">Группу.</param>
        /// <returns>Идентификатор созданной группу.</returns>
        public int Create(TeamItem team)
        {
            using (var sqlh = new SqlHelper())
            {
                return sqlh.ExecScalar<int>(@"
            insert into Team.Team
            (
            name,
            create_date,
            specialty_detail
            )
            values
            (
            @Name,
            @CreateDate,
            @SpecialtyDetailId
            )

            select scope_identity()", team);
            }
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            _transactionScope = new TransactionScope();
            _studentRepository = new StudentRepository();
            _personRepository = new PersonRepository();
            _teamRepository = new TeamRepository();
            _specialtyDetailRepository = new SpecialtyDetailRepository();
            _specialtyRepository = new SpecialtyRepository();
            _cathedraRepository = new CathedraRepository();
            _facultyRepository = new FacultyRepository();

            _team = new TeamItem()
            {
                CreateDate = DateTime.Now,
                Name = "ПЕ-22б",
                SpecialtyDetailId = _specialtyDetailRepository.Create(new SpecialtyDetailItem()
                {
                    SpecialtyId = _specialtyRepository.Create(new SpecialtyItem()
                    {
                        CathedraId = _cathedraRepository.Create(new CathedraItem()
                        {
                            FacultyId = _facultyRepository.Create(new FacultyItem()),
                            FullName = "Кафедра",
                            ShortName = "K"
                        }),
                        FullName = "Специальность",
                        ShortName = "С",
                        Code = "1"
                    }),
                    ActualDate = DateTime.Now
                })
            };

            _student = new StudentItem()
            {
                LastName = "Егоров",
                FirstName = "Виталий",
                FatherName = "Игоревич",
                Birthday = DateTime.Now,
                TeamId = _teamRepository.Create(_team)
            };
            _student.Id = _personRepository.Create(_student);

            _studentNew = new StudentItem()
            {
                LastName = "Журавлев",
                FirstName = "Данил",
                FatherName = "Александрович",
                Birthday = DateTime.Now,
                TeamId = _teamRepository.Create(_team)
            };
            _studentNew.Id = _personRepository.Create(_student);
        }
Ejemplo n.º 4
0
        public void SetUp()
        {
            _teamRepository = Mock.Of<ITeamRepository>();
            _teamService = new TeamService(_teamRepository);

            _team = new TeamItem()
            {
                Id = 1,
                Name = "Назване группы",
                CreateDate = DateTime.Now.Date,
                SpecialtyDetailId = 1
            };
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Обновляет данные по группе.
 /// </summary>
 /// <param name="Team">Группу.</param>
 public void Update(TeamItem Team)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Создает новую группу.
 /// </summary>
 /// <param name="Team">Группу.</param>
 /// <returns>Идентификатор созданной группу.</returns>
 public int Create(TeamItem Team)
 {
     return 0;
 }
Ejemplo n.º 7
0
        public void SetUp()
        {
            _transactionScope = new TransactionScope();
            _teamRepository = new TeamRepository();
            _specialtyDetailRepository = new SpecialtyDetailRepository();
            _specialtyRepository = new SpecialtyRepository();
            _cathedraRepository = new CathedraRepository();
            _facultyRepository = new FacultyRepository();

            var specialty_detail = new SpecialtyDetailItem()
                {
                    SpecialtyId =_specialtyRepository.Create(new SpecialtyItem()
                    {
                        CathedraId = _cathedraRepository.Create(new CathedraItem()
                        {
                            FacultyId = _facultyRepository.Create(new FacultyItem()),
                            FullName = "Кафедра",
                            ShortName = "K"
                        }),
                        FullName = "Специальность",
                        ShortName = "С",
                        Code = "1"
                    }),
                    ActualDate = DateTime.Now
                };
            _team = new TeamItem()
            {
                Name = "ПЕ-22б",
                CreateDate = DateTime.Now.Date,
                SpecialtyDetailId = _specialtyDetailRepository.Create(specialty_detail)
            };
            _teamNew = new TeamItem()
            {
                Name = "ПЕ-21б",
                CreateDate = DateTime.Now.AddYears(-1).Date,
                SpecialtyDetailId = _specialtyDetailRepository.Create(specialty_detail)
            };
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Проверяет эквивалентны ли две группы.
 /// </summary>
 /// <param name="first_team">Первая группа для сравнения.</param>
 /// <param name="second_team">Вторая группа для сравнения.</param>
 private void AreEqualTeams(TeamItem first_team, TeamItem second_team)
 {
     Assert.AreEqual(first_team.Id, second_team.Id);
     Assert.AreEqual(first_team.Name, second_team.Name);
     Assert.AreEqual(first_team.CreateDate, second_team.CreateDate);
 }
Ejemplo n.º 9
0
 public ActionResult Create(TeamItem team)
 {
     Access.CheckAccess("Team.Creator");
     return RedirectToAction("Index", new { id = _teamService.Create(team) });
 }
Ejemplo n.º 10
0
 public ActionResult Update(TeamItem team)
 {
     Access.CheckAccess("Team.Updater");
     _teamService.Update(team);
     return RedirectToAction("Index", new { id = team.Id });
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Обновляет данные по группе.
 /// </summary>
 /// <param name="team">Группу.</param>
 public void Update(TeamItem team)
 {
     using (var sqlh = new SqlHelper())
     {
         sqlh.ExecNoQuery(@"
     update Team.Team
     set
     name = @Name,
     create_date = @CreateDate,
     specialty_detail = @SpecialtyDetailId
     where Team = @Id", team);
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Обновляет данные по группе.
 /// </summary>
 /// <param name="team">Группа.</param>
 public void Update(TeamItem team)
 {
     if (string.IsNullOrWhiteSpace(team.Name))
     {
         throw new Exception("Поле 'Name' не должно быть пустым.");
     }
     if (GetById(team.Id) == null)
     {
         throw new Exception("Группа не найдена.");
     }
     _teamRepository.Update(team);
 }