Ejemplo n.º 1
0
        public Collection <Task> GetByUser(int devID)
        {
            Query query = TaskAssignment.CreateQuery().AddWhere(TaskAssignment.Columns.UserID, Comparison.Equals, devID);
            TaskAssignmentCollection assignmentCollection = _taskAssignmentController.FetchByQuery(query);

#warning //TODO: optimize
            Collection <Task> tasks = new Collection <Task>();
            foreach (TaskAssignment assignment in assignmentCollection)
            {
                tasks.Add(CreateRecord(assignment.Task));
            }

            return(tasks);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Assigns the task.
        /// </summary>
        /// <param name="taskID">The task ID.</param>
        /// <param name="devID">The dev ID.</param>
        /// <returns></returns>
        public void Assign(int taskID, int devID)
        {
            if (!Exists(taskID))
            {
                throw new ServiceException(String.Format("A task with ID = {0} does not exist.", taskID));
            }

            UserService userService = new UserService();

            if (!userService.Exists(devID))
            {
                throw new ServiceException(String.Format("A user with ID = {0} does not exist.", devID));
            }

            Query query = TaskAssignment.CreateQuery()
                          .AddWhere(TaskAssignment.Columns.TaskID, Comparison.Equals, taskID);

            if (_taskAssignmentController.FetchByQuery(query).Count != 0)
            {
                throw new ServiceException(String.Format("Task with ID = {0} is already assigned.", taskID));
            }

            _taskAssignmentController.Insert(taskID, devID);
        }