Пример #1
0
        public TaskCompletionStatus SetTaskIsCompleted(int taskID, bool value)
        {
            TaskCompletionStatus result = new TaskCompletionStatus(false, value);

            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Task      task      = Tasks.GetTask(loginUser, taskID);

            task.IsComplete = value;

            //if a user is attempting to complete a task check for incomplete subtasks first
            if (value)
            {
                if (GetIncompleteSubtasks(taskID))
                {
                    result.IncompleteSubtasks = true;
                    result.Value = !value;
                    return(result);
                }
                task.DateCompleted   = DateTime.UtcNow;
                result.DateCompleted = task.DateCompleted;
            }
            else
            {
                result.IncompleteSubtasks = false;
                result.Value       = value;
                task.DateCompleted = null;
            }

            //We are clearing completion comments as they could or not be set in next call.
            task.CompletionComment = null;
            task.Collection.Save();
            string description = String.Format("{0} set task is complete to {1} ", TSAuthentication.GetUser(loginUser).FirstLastName, value);

            TaskLogs.AddTaskLog(loginUser, taskID, description);

            if (task.IsComplete && (loginUser.UserID != task.CreatorID || (task.UserID != null && loginUser.UserID != task.UserID)))
            {
                SendCompletedNotification(loginUser.UserID, task.TaskID);
            }
            else if (task.UserID != null && loginUser.UserID != task.UserID)
            {
                SendModifiedNotification(loginUser.UserID, task.TaskID);
            }

            return(result);
        }
Пример #2
0
        public TaskCompletionStatus AddTaskCompleteComment(int taskID, string comment)
        {
            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Task      task      = Tasks.GetTask(loginUser, taskID);

            task.CompletionComment = comment;
            task.Collection.Save();

            //string description = String.Format(@"{0} added task complete note: ""{1}""", TSAuthentication.GetUser(loginUser).FirstLastName, comment);
            string description = String.Format(@"{0} added task complete note.", TSAuthentication.GetUser(loginUser).FirstLastName);

            TaskLogs.AddTaskLog(loginUser, taskID, description);

            TaskCompletionStatus result = new TaskCompletionStatus(false, true);

            result.DateCompleted     = task.DateCompleted;
            result.CompletionComment = task.CompletionComment;
            return(result);
        }