public void GetByPersonId_Void_ReturnNotEmpty() { var person = new PersonItem() { Id = 1, }; var result = _userRepository.GetByPersonId(person.Id); Assert.IsNull(result); }
/// <summary> /// Создает человека. /// </summary> /// <param name="person">Человек.</param> /// <returns>Идентификаторо созданного человека.</returns> public int Create(PersonItem person) { if (string.IsNullOrEmpty(person.FirstName)) { throw new Exception("Поле 'FirstName' не должно быть пустым."); } if (string.IsNullOrEmpty(person.FatherName)) { throw new Exception("Поле 'FatherName' не должно быть пустым."); } if (string.IsNullOrEmpty(person.LastName)) { throw new Exception("Поле 'LastName' не должно быть пустым."); } return _personRepository.Create(person); }
/// <summary> /// Создает нового человека. /// </summary> /// <param name="person">Задача.</param> /// <returns>Идентификатор созданного человека.</returns> 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); } }
public ActionResult Create(PersonItem person) { Access.CheckAccess("Person.Creator"); return RedirectToAction("Index", new { id = _personService.Create(person) }); }
public ActionResult Update(PersonItem person) { Access.CheckAccess("Person.Updater"); _personService.Update(person); return RedirectToAction("Index", new { id = person.Id }); }
/// <summary> /// Интерфейс для создания человека. /// </summary> /// <returns></returns> public ActionResult New() { Access.CheckAccess("Person.Creator"); var default_item = new PersonItem { LastName = "", FirstName = "", FatherName = "" }; return View(default_item); }
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) }; }
public void SetUp() { _personRepository = Mock.Of<IPersonRepository>(); _personService = new PersonService(_personRepository); _person = new PersonItem() { FirstName = "Василий", FatherName = "Петрович", LastName = "Иванов", Birthday = DateTime.Now.Date }; }
public void SetUp() { _transactionScope = new TransactionScope(); _personRepository = new PersonRepository(); _person = new PersonItem() { Id = 1, LastName = "Иванов", FirstName = "Василий", Birthday = DateTime.Now.Date, FatherName = "Иванович" }; _personNew = new PersonItem() { Id = 1, LastName = "Пупкин", FirstName = "Сергей", Birthday = DateTime.Now.Date, FatherName = "Петрович" }; }
/// <summary> /// Проверяет эквивалентны ли два человека. /// </summary> /// <param name="first_person"></param> /// <param name="second_person"></param> private void AreEqualPerson(PersonItem first_person, PersonItem second_person) { Assert.AreEqual(first_person.Id, second_person.Id); Assert.AreEqual(first_person.LastName, second_person.LastName); Assert.AreEqual(first_person.FirstName, second_person.FirstName); Assert.AreEqual(first_person.FatherName, second_person.FatherName); Assert.AreEqual(first_person.Birthday, second_person.Birthday); }
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 }; }
/// <summary> /// Измененяет данные о человеке. /// </summary> /// <param name="person">Человек.</param> public void Update(PersonItem person) { if (string.IsNullOrEmpty(person.FirstName)) { throw new Exception("Поле 'FirstName' не должно быть пустым."); } if (string.IsNullOrEmpty(person.FatherName)) { throw new Exception("Поле 'FatherName' не должно быть пустым."); } if (string.IsNullOrEmpty(person.LastName)) { throw new Exception("Поле 'LastName' не должно быть пустым."); } if (GetById(person.Id) == null) { throw new Exception("Человек не найден."); } _personRepository.Update(person); }
/// <summary> /// Обновляет данные у человека. /// </summary> /// <param name="person">Человека.</param> public void Update(PersonItem person) { using (var sqlh = new SqlHelper()) { sqlh.ExecNoQuery(@" update Person.person set last_name = @LastName, first_name = @FirstName, father_name = @FatherName, birthday = @Birthday where person = @Id", person); } }