IS.Model.Repository.Person.PersonRepository.Create C# (CSharp) Method

Create() public method

Создает нового человека.
public Create ( PersonItem person ) : int
person IS.Model.Item.Person.PersonItem Задача.
return int
        public int Create(PersonItem person)
        {
            using (var sqlh = new SqlHelper())
            {
                return sqlh.ExecScalar<int>(@"
            insert into Person.person
            (
            last_name,
            first_name,
            father_name,
            birthday
            )
            values
            (
            @LastName,
            @FirstName,
            @FatherName,
            @Birthday
            )

            select scope_identity()", person);
            }
        }

Usage Example

Ejemplo n.º 1
0
        public void SetUp()
        {
            _transactionScope = new TransactionScope();
            _commentRepository = new CommentRepository();
            _personRepository = new PersonRepository();
            _taskRepository = new TaskRepository();

            first_person = new PersonItem()
            {
                LastName = "Никонов",
                FirstName = "Денис",
                Birthday = DateTime.Now.Date,
                FatherName = "Олегович"
            };

            second_person = new PersonItem()
            {
                LastName = "Кажин",
                FirstName = "Филипп",
                Birthday = DateTime.Now.AddMonths(-3).Date,
                FatherName = "Александрович"
            };

            first_task = new TaskItem()
            {
                Author = "1",
                Deadline = DateTime.Now.AddDays(7).Date,
                Created = DateTime.Now.Date,
                Performer = "1",
                Header = "Тестирование демонстрационной задачи",
                IsOpen = true,
                IsPerform = false,
                Mem = "Описание",
                Number = 1,
                Priority = 0,
                Prefix = TaskPrefix.Refactoring
            };

            second_task = new TaskItem()
            {
                Author = "2",
                Deadline = DateTime.Now.AddDays(8).Date,
                Created = DateTime.Now.Date,
                Performer = "2",
                Header = "Тестирование демонстрационной задачи 2",
                IsOpen = false,
                IsPerform = true,
                Mem = "Описание2",
                Number = 2,
                Priority = 5,
                Prefix = TaskPrefix.Demo
            };

            _comment = new CommentItem()
            {
                AddDate = DateTime.Now.Date,
                PersonId = _personRepository.Create(first_person),
                Text = "Задача номер 1",
                TaskId = _taskRepository.Create(first_task)
            };
            _commentNew = new CommentItem()
            {
                AddDate = DateTime.Now.AddYears(-1).Date,
                PersonId = _personRepository.Create(second_person),
                Text = "Задача номер 2",
                TaskId = _taskRepository.Create(second_task)
            };
        }
All Usage Examples Of IS.Model.Repository.Person.PersonRepository::Create