Класс для хранения данных по задаче.
Example #1
0
        /// <summary>
        /// Создает новую задачу.
        /// </summary>
        /// <param name="task">Задача.</param>
        /// <returns>Идентификатор созданной задачи.</returns>
        public int Create(TaskItem task)
        {
            using (var sqlh = new SqlHelper())
            {
                return sqlh.ExecScalar<int>(@"
            insert into Task.task
            (
            number,
            task_prefix,
            header,
            mem,
            deadline,
            priority,
            performer,
            author
            )
            values
            (
            @Number,
            (select top 1 p.task_prefix from Task.task_prefix p where p.code = @Prefix),
            @Header,
            @Mem,
            @Deadline,
            @Priority,
            @Performer,
            @Author
            )

            select scope_identity()", task);
            }
        }
Example #2
0
        /// <summary>
        /// Создает задачу.
        /// </summary>
        /// <param name="task">Задача.</param>
        /// <returns>Идентификаторо созданной задачи.</returns>
        public int Create(TaskItem task)
        {
            if (string.IsNullOrEmpty(task.Header))
            {
                throw new Exception("Поле 'Header' не должно быть пустым.");
            }

            if (string.IsNullOrEmpty(task.Mem))
            {
                throw new Exception("Поле 'Mem' не должно быть пустым.");
            }

            var list = GetList().FindAll(x => x.Prefix == task.Prefix);
            if (list.Any())
            {
                task.Number = GetList().FindAll(x => x.Prefix == task.Prefix).Max(y => y.Number) + 1;
            }
            else
            {
                task.Number = 1;
            }

            return _taskRepository.Create(task);
        }
Example #3
0
        public void SetUp()
        {
            _taskRepository = Mock.Of<ITaskRepository>();
            _taskService = new TaskService(_taskRepository, _commentRepository);

            _task = new TaskItem()
            {
                Id = 1,
                Author = "",
                Deadline = DateTime.Now.AddDays(7).Date,
                Created = DateTime.Now.Date,
                Performer = "",
                Header = "Тестирование демонстрационной задачи",
                IsOpen = true,
                IsPerform = false,
                Mem = "Описание",
                Number = 1,
                Priority = 0,
                Prefix = TaskPrefix.Refactoring
            };
        }
Example #4
0
 /// <summary>
 /// Обновляет данные по задаче.
 /// </summary>
 /// <param name="task">Задача.</param>
 public void Update(TaskItem task)
 {
     using (var sqlh = new SqlHelper())
     {
         sqlh.ExecNoQuery(@"
     update Task.task
     set
     number = @Number,
     task_prefix = (select top 1 p.task_prefix from Task.task_prefix p where p.code = @Prefix),
     header = @Header,
     mem = @Mem,
     deadline = @Deadline,
     priority = @Priority,
     performer = @Performer,
     author = @Author,
     is_perform = @IsPerform,
     is_open = @IsOpen
     where task = @Id", task);
     }
 }
Example #5
0
        public void SetUp()
        {
            _transactionScope = new TransactionScope();
            _taskRepository = new TaskRepository();

            _task = new TaskItem()
            {
                Author = "",
                Deadline = DateTime.Now.AddDays(7).Date,
                Created = DateTime.Now.Date,
                Performer = "",
                Header = "Тестирование демонстрационной задачи",
                IsOpen = true,
                IsPerform = false,
                Mem = "Описание",
                Number = 1,
                Priority = 0,
                Prefix = TaskPrefix.Refactoring
            };
            _taskNew = new TaskItem()
            {
                Author = "1",
                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
            };
        }
Example #6
0
 /// <summary>
 /// Проверяет еквивалентны ли две задачи.
 /// </summary>
 /// <param name="first_task"></param>
 /// <param name="second_task"></param>
 private void AreEqualTasks(TaskItem first_task, TaskItem second_task)
 {
     Assert.AreEqual(first_task.Id, second_task.Id);
     Assert.AreEqual(first_task.Author, second_task.Author);
     Assert.AreEqual(first_task.Deadline, second_task.Deadline);
     Assert.AreEqual(first_task.Performer, second_task.Performer);
     Assert.AreEqual(first_task.Header, second_task.Header);
     Assert.AreEqual(first_task.IsOpen, second_task.IsOpen);
     Assert.AreEqual(first_task.IsPerform, second_task.IsPerform);
     Assert.AreEqual(first_task.Mem, second_task.Mem);
     Assert.AreEqual(first_task.Number, second_task.Number);
     Assert.AreEqual(first_task.Priority, second_task.Priority);
     Assert.AreEqual(first_task.Prefix, second_task.Prefix);
 }
Example #7
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)
            };
        }
Example #8
0
        /// <summary>
        /// Измененяет данные о задаче.
        /// </summary>
        /// <param name="task">Задача.</param>
        public void Update(TaskItem task)
        {
            if (string.IsNullOrEmpty(task.Header))
            {
                throw new Exception("Поле 'Header' не должно быть пустым.");
            }

            if (string.IsNullOrEmpty(task.Mem))
            {
                throw new Exception("Поле 'Mem' не должно быть пустым.");
            }

            if (GetById(task.Id) == null)
            {
                throw new Exception("Задача не найдена.");
            }

            _taskRepository.Update(task);
        }
Example #9
0
 public ActionResult Create(TaskItem task)
 {
     Access.CheckAccess("Task.Creator");
     return RedirectToAction("Index", new { id = _taskService.Create(task) });
 }
Example #10
0
 public ActionResult Update(TaskItem task)
 {
     Access.CheckAccess("Task.Updater");
     _taskService.Update(task);
     return RedirectToAction("Index", new { id = task.Id });
 }
Example #11
0
 /// <summary>
 /// Интерфейс для создания задачи.
 /// </summary>
 /// <returns></returns>
 public ActionResult New()
 {
     Access.CheckAccess("Task.Creator");
     var default_item = new TaskItem
     {
         Difficult = 1,
         Priority = 3
     };
     return View(default_item);
 }
Example #12
0
        public ActionResult Update(TaskItem task)
        {
            var origin_task = _taskService.GetById(task.Id);
            if (!Access.CheckRole("Task.Updater.Header"))
            {
                task.Header = origin_task.Header;
            }
            if (!Access.CheckRole("Task.Updater.Priority"))
            {
                task.Priority = origin_task.Priority;
            }
            if (!Access.CheckRole("Task.Updater.Difficult"))
            {
                task.Difficult = origin_task.Difficult;
            }
            if (!Access.CheckRole("Task.Updater.Deadline"))
            {
                task.Deadline = origin_task.Deadline;
            }
            if (!Access.CheckRole("Task.Updater.Mem"))
            {
                task.Mem = origin_task.Mem;
            }
            if (!Access.CheckRole("Task.Updater.Performer"))
            {
                task.Performer = origin_task.Performer;
            }
            if (!Access.CheckRole())
            {
                task.PullRequestUrl = origin_task.PullRequestUrl;
            }

            _taskService.Update(task);
            return RedirectToAction("Index", new { id = task.Id });
        }