Example #1
0
        /// <summary>
        /// Simple constructor of the board, so it need an email(unique) in order to create a new one for a new user!
        /// </summary>
        /// <param name="email"></param>
        public Board(string email)
        {
            taskId       = 1;
            Email        = email;
            boardColumns = new List <Column>();

            columnDalController = new DataAccess_Layer.ColumnDalController();
            taskDalController   = new DataAccess_Layer.TaskDalController();

            Column c1 = new Column("backlog");

            c1.Email    = email;
            c1.columnID = 0;

            columnDalController.Insert(c1.ToDalObject());
            Column c2 = new Column("in progress");

            c2.Email    = email;
            c2.columnID = 1;

            columnDalController.Insert(c2.ToDalObject());
            Column c3 = new Column("done");

            c3.Email    = email;
            c3.columnID = 2;
            columnDalController.Insert(c3.ToDalObject());

            boardColumns.Add(c1);
            boardColumns.Add(c2);
            boardColumns.Add(c3);
        }
Example #2
0
 /// <summary>
 /// Initializig a new column with a UNIQUE name!
 /// So we check the validity of the name in checkValid func
 /// </summary>
 /// <param name="name"> column name </param>
 public Column(string name)
 {
     checkValid(name);
     this.name         = name;
     Tasks             = new List <Task>();
     NumberOfTasks     = 0;
     limit             = DEFAULT_LIMIT; //which means there is no limit by default
     taskDalController = new DataAccess_Layer.TaskDalController();
 }
Example #3
0
 /// <summary>
 /// Simple constructor
 /// </summary>
 public BoardController()
 {
     boardController = new Dictionary <string, Board>();
     userOnline      = new Dictionary <string, bool>();
     UsersOfBoard    = new Dictionary <string, List <string> >();
     DataOfBoard     = new DataAccess_Layer.BoardDalController();
     DataOfTask      = new DataAccess_Layer.TaskDalController();
     DataOfColumn    = new DataAccess_Layer.ColumnDalController();
     id = 0;
 }
Example #4
0
        /// <summary>
        /// Simple construcotr that converts DAL-column to BL-Column
        /// </summary>
        /// <param name="c"></param>
        public Column(DataAccess_Layer.DTOs.ColumnDTO c)
        {
            this.name  = c.Name;
            this.limit = c.Limit;
            columnID   = c.ColID;
            Email      = c.Email;
            List <Task>    tasks         = new List <Task>();
            List <TaskDTO> tasksDTO_list = new List <TaskDTO>();

            taskDalController = new DataAccess_Layer.TaskDalController();
            tasksDTO_list     = taskDalController.SelectUserTasks(Email, name);
            foreach (DataAccess_Layer.DTOs.TaskDTO t in tasksDTO_list)
            {
                tasks.Add(new Task(t));
            }
            this.Tasks         = tasks;
            this.NumberOfTasks = Tasks.Count;
        }
Example #5
0
 /// <summary>
 /// Removing an exists column from the board!
 /// WE musts have minimum 2 columns on the board! so if the NumberOfColumns equals to 2 throws an error!
 /// All the tasks are moved to the neighbor column but only if the neighbor coloum has limit > NumOfHisTasks + NumOfOtherTasks
 /// </summary>
 /// <param name="columnID"> unique id for the column to be moved! </param>
 public void removeColumn(int columnID) // 0 (1) 2
 {
     taskDalController   = new DataAccess_Layer.TaskDalController();
     columnDalController = new DataAccess_Layer.ColumnDalController();
     if (columnID < 0 || columnID >= boardColumns.Count || boardColumns.Count == 2)
     {
         throw new Exception("Board must have minmum of 2 columns!");
     }
     if (columnID == 0)
     {
         if (!(getColumnById(1).getLimit() == -1) && getColumnById(1).getNumberOfTasks() + getColumnById(0).getNumberOfTasks() > getColumnById(1).getLimit())
         {
             throw new Exception("Couldnt remove the column!");
         }
         foreach (Task t in getColumnById(columnID).getTasks())
         {
             taskDalController.Delete(t.ToDalObject());
             boardColumns[1].addTask(t, t.getId());
         }
     }
     else
     {
         if (!(getColumnById(columnID - 1).getLimit() == -1) && getColumnById(columnID - 1).getNumberOfTasks() + getColumnById(columnID).getNumberOfTasks() > getColumnById(columnID - 1).getLimit())
         {
             throw new Exception("Couldnt remove the column!");
         }
         foreach (Task t in getColumnById(columnID).getTasks())
         {
             taskDalController.Delete(t.ToDalObject());
             boardColumns[columnID - 1].addTask(t, t.getId());
         }
     }
     columnDalController.Delete(getColumnById(columnID).ToDalObject());
     //Shifting columns back.
     for (int i = columnID + 1; i < boardColumns.Count; i++)
     {
         boardColumns.ElementAt(i).columnID--; // done id = 1
         boardColumns.ElementAt(i).Save();
     }
     boardColumns.RemoveAt(columnID);
     Save();//Saving board due to columns decrement.
 }