Exemplo n.º 1
0
        /// <summary>
        /// This function is responsible for changing a state of a given Task
        /// </summary>
        /// <param name="task"> Task instance to be moved </param>
        public bool ChangeState(Task task, string boardName, string email)
        {
            string currCol = task.GetState(); // string that represents current state or column, for example : "backlog"
            // Get index of current column
            int    currentIndex = this.columns.FirstOrDefault(x => ((Column)x.Value).GetColumnName().Equals(currCol)).Key;
            Column currentCol   = this.columns[currentIndex];

            if (!(currentIndex == this.columns.Keys.Last()))  // Checking whether the state changing occurs in the next column
            {
                int    movingIndex = currentIndex + 1;
                Column movingCol   = this.columns[movingIndex];

                if ((movingCol.GetIsLimited() && movingCol.GetTasks().Count < movingCol.GetLim()) || (!movingCol.GetIsLimited()))
                {
                    task.SetState(movingCol.GetColumnName());
                    movingCol.AddTaskToColumn(task, movingIndex, boardName, email);
                    currentCol.RemoveTask(task, currentIndex, boardName, email);
                    this.dataBase.MoveTask(email, boardName, Convert.ToString(task.GetCreationTime()), Convert.ToString(task.GetDueDate()), currCol, task.GetTitle(), task.GetDescription(), movingCol.GetColumnName());
                    return(true);
                }
                else
                {
                    Logger.GetLogger().Error("changing state couldn't been preformed.Limitation error!!");
                    return(false);
                }
            }
            else
            {
                Logger.GetLogger().Error("Can't move task from last column");
                return(false);
            }
        }