Beispiel #1
0
        ///<summary>
        ///      Restore all tasks From DB and add them to relevant tasks Collection
        ///      <example>
        ///        <code>
        ///          Board.RestoreFromDB();
        ///        </code>
        ///      </example>
        ///    </summary>
        public static void RestoreFromDB()
        {
            long openColumnId    = GetKeyForValue("Open", Columns).columnId;
            long codingColumnId  = GetKeyForValue("Coding", Columns).columnId;
            long testColumnId    = GetKeyForValue("Test", Columns).columnId;
            long resolveColumnId = GetKeyForValue("Resolve", Columns).columnId;

            var openTasks    = BoardDB.GetTasksAndEmployeesFromColumn(openColumnId);
            var codingTasks  = BoardDB.GetTasksAndEmployeesFromColumn(codingColumnId);
            var testTasks    = BoardDB.GetTasksAndEmployeesFromColumn(testColumnId);
            var resolveTasks = BoardDB.GetTasksAndEmployeesFromColumn(resolveColumnId);

            foreach (TaskAndEmploy t in openTasks)
            {
                OpenTasksList.Add(t);
            }

            foreach (TaskAndEmploy t in codingTasks)
            {
                CodingTasksList.Add(t);
            }

            foreach (TaskAndEmploy t in testTasks)
            {
                TestsTasksList.Add(t);
            }

            foreach (TaskAndEmploy t in resolveTasks)
            {
                ResolveTasksList.Add(t);
            }
        }
Beispiel #2
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string   name     = txtName.Text;
                string   surname  = txtSurname.Text;
                Position position = Board.PositionsList.First(p => p.ToString() == cbPosition.Text);

                Board.CurrentlySelectedEmploy.employ.Name       = name;
                Board.CurrentlySelectedEmploy.employ.Surname    = surname;
                Board.CurrentlySelectedEmploy.employ.positionId = position.positionId;
                Board.CurrentlySelectedEmploy.position          = position;

                if (BoardDB.GetDB().SaveChanges() == 1)
                {
                    CollectionViewSource.GetDefaultView(Board.EmployAndPositionList).Refresh();
                    Board.ClearListsAndRestoreFromDB();
                    this.NavigationService.GoBack();
                }
                else
                {
                    lblError.Content = "Błąd edycji";
                }
            }
            catch (InvalidOperationException err)
            {
                lblError.Content = err.Message;
            }
        }
        public EditTaskPage()
        {
            InitializeComponent();

            txtName.Text               = Board.CurrentlySelectedTask.Name;
            txtDescription.Text        = Board.CurrentlySelectedTask.Description;
            pickerDateEnd.SelectedDate = Board.CurrentlySelectedTask.TaskEndDate;

            foreach (var s in Board.Estimates)
            {
                cbEstimation.Items.Add(s.Value);
            }

            foreach (var s in Board.Columns)
            {
                cbColumn.Items.Add(s.Value);
            }

            foreach (var employ in BoardDB.GetEmployees())
            {
                cbAssignee.Items.Add(employ);
            }

            cbEstimation.Text = Board.CurrentlySelectedTask.Estimation;
            cbColumn.Text     = Board.Columns[Board.CurrentlySelectedTask.task.columnId].ToString();
            cbAssignee.Text   = Board.CurrentlySelectedTask.Assign;
        }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string name        = txtName.Text;
                string description = txtDescription.Text;

                Employ   assignee = BoardDB.GetEmployees().ToList().FirstOrDefault(employ => employ.ToString() == cbAssignee.Text);
                DateTime endDate  = (DateTime)pickerDateEnd.SelectedDate;

                Board.CurrentlySelectedTask.task.Name           = name;
                Board.CurrentlySelectedTask.task.Description    = description;
                Board.CurrentlySelectedTask.task.TaskEndDate    = endDate;
                Board.CurrentlySelectedTask.task.LastModifyDate = DateTime.Now;
                Board.CurrentlySelectedTask.task.employId       = assignee.employId;
                Board.CurrentlySelectedTask.task.Estimation     = Board.GetKeyForValue(cbEstimation.Text, Board.Estimates).estimateId;

                Board.CurrentlySelectedTask.employ = assignee;

                Column newColumn = Board.GetKeyForValue(cbColumn.Text, Board.Columns);
                Board.CurrentlySelectedTask.task.columnId = newColumn.columnId;

                BoardDB.GetDB().SaveChanges();
                Board.ClearListsAndRestoreFromDB();

                MainBoardPage boardPage = new MainBoardPage();
                this.NavigationService.Navigate(boardPage);
            }
            catch (InvalidOperationException err)
            {
                lblError.Content = err.Message;
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string   name     = txtName.Text;
                string   surname  = txtSurname.Text;
                Position position = Board.PositionsList.First(p => p.ToString() == cbPosition.Text);

                var employ = new Employ(name, surname, position.positionId);

                BoardDB.GetEmployees().Add(employ);
                if (BoardDB.GetDB().SaveChanges() == 1)
                {
                    Board.EmployAndPositionList.Add(new EmployAndPosition(employ, position));

                    this.NavigationService.GoBack();
                }
                else
                {
                    lblError.Content = "Błąd dodawania";
                }
            }
            catch (InvalidOperationException err)
            {
                lblError.Content = err.Message;
            }
        }
        ///   <summary>
        ///      returns employees with position from BD
        ///      <example>
        ///        <code>
        ///             IQueryable<EmployAndPosition> t = BoardDB.GetEmployeesAndPosition();
        ///        </code>
        ///      </example>
        ///    </summary>
        public static IQueryable <EmployAndPosition> GetEmployeesAndPosition()
        {
            var positions = BoardDB.GetPositions();
            var employees = BoardDB.GetEmployees();

            return(employees
                   .Join(positions, employ => employ.positionId, position => position.positionId,
                         (e, p) => new EmployAndPosition(e, p)));
        }
Beispiel #7
0
        ///   <summary>
        ///      removes selected task
        ///      <example>
        ///        <code>
        ///             Board.RemoveSelectedTask();
        ///        </code>
        ///      </example>
        ///    </summary>
        public static void RemoveSelectedTask()
        {
            BoardDB.GetTasks().Remove(Board.CurrentlySelectedTask.task);

            if (BoardDB.SaveChanges() == 1)
            {
                Board.GetListBasedOnSelectedColumn().RemoveAt(Board.CurrentlySelectedIndex);
            }
        }
Beispiel #8
0
        ///<summary>
        ///      Get Columns from DB and add them to Board.Columns Dictionary
        ///      <example>
        ///        <code>
        ///          Board.GetColumns();
        ///        </code>
        ///      </example>
        ///    </summary>
        public static void GetColumns()
        {
            var columns = BoardDB.GetColumns();

            foreach (var c in columns)
            {
                Board.Columns.Add(c.columnId, c);
            }
        }
Beispiel #9
0
        ///     <summary>
        ///      Get Estimates from DB and add them to Board.Estimates Dictionary
        ///      <example>
        ///        <code>
        ///          Board.GetEstimations();
        ///        </code>
        ///      </example>
        ///    </summary>
        public static void GetEstimations()
        {
            var estimations = BoardDB.GetEstimations();

            foreach (var est in estimations)
            {
                Board.Estimates.Add(est.estimateId, est);
            }
        }
        ///   <summary>
        ///      returns tasks with employees from BD
        ///      <example>
        ///        <code>
        ///             long openColumnId = GetKeyForValue("Open", Columns).columnId;<para/>
        ///             IQueryable<TaskAndEmploy> t = BoardDB.GetTasksAndEmployeesFromColumn(openColumnId);
        ///        </code>
        ///      </example>
        ///    </summary>
        public static IQueryable <TaskAndEmploy> GetTasksAndEmployeesFromColumn(long columnId)
        {
            var tasks     = BoardDB.GetTasks();
            var employees = BoardDB.GetEmployees();

            return(tasks
                   .Where(t => t.columnId == columnId)
                   .Join(employees, task => task.employId, employ => employ.employId,
                         (t, e) => new TaskAndEmploy(t, e)));
        }
Beispiel #11
0
        ///<summary>
        ///      Adding new task to open column
        ///      <example>
        ///        <code>
        ///          Task task = new Task(); <para/>
        ///          Board.AddNewTaskToBoard(task);
        ///        </code>
        ///      </example>
        ///    </summary>
        public static void AddNewTaskToBoard(Task task)
        {
            BoardDB.GetTasks().Add(task);

            if (BoardDB.SaveChanges() == 1)
            {
                var employ = BoardDB.GetEmploy(task.employId);

                OpenTasksList.Add(new TaskAndEmploy(task, employ));
            }
        }
Beispiel #12
0
        ///<summary>
        ///      Get EmployeesAndPositions from DB and add them to Board.GetEmployeesAndPositions Collection
        ///      <example>
        ///        <code>
        ///          Board.GetEmployeesAndPositions();
        ///        </code>
        ///      </example>
        ///    </summary>
        public static void GetEmployeesAndPositions()
        {
            Board.EmployAndPositionList.Clear();
            var positions = BoardDB.GetEmployeesAndPosition();

            foreach (var p in positions)
            {
                if (p.employ.employId != 0)
                {
                    Board.EmployAndPositionList.Add(p);
                }
            }
        }
Beispiel #13
0
        ///<summary>
        ///      Get Positions from DB and add them to Board.PositionsList Dictionary
        ///      <example>
        ///        <code>
        ///          Board.GetPositions();
        ///        </code>
        ///      </example>
        ///    </summary>

        public static void GetPositions()
        {
            Board.PositionsList.Clear();
            var positions = BoardDB.GetPositions();

            foreach (var p in positions)
            {
                if (p.positionId != 0)
                {
                    Board.PositionsList.Add(p);
                }
            }
        }
        public AddNewCardPage()
        {
            InitializeComponent();
            foreach (var s in Board.Estimates)
            {
                cbEstimation.Items.Add(s.Value);
            }

            foreach (var employ in BoardDB.GetEmployees())
            {
                cbAssignee.Items.Add(employ);

                if (employ.employId == 0)
                {
                    cbAssignee.Text = employ.ToString();
                }
            }

            cbEstimation.Text          = Board.Estimates.First().Value.Name;
            pickerDateEnd.SelectedDate = DateTime.Now.AddDays(7);
        }
Beispiel #15
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string name     = txtName.Text;
                var    position = new Position(name);

                BoardDB.GetPositions().Add(position);
                if (BoardDB.GetDB().SaveChanges() == 1)
                {
                    Board.PositionsList.Add(position);
                    this.NavigationService.GoBack();
                }
                else
                {
                    lblError.Content = "Błąd dodawania";
                }
            }
            catch (InvalidOperationException err)
            {
                lblError.Content = err.Message;
            }
        }
        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            int index = ListOfPositions.SelectedIndex;

            if (index >= 0)
            {
                var position = Board.PositionsList[index];

                if (position.positionId != 0)
                {
                    BoardDB.GetPositions().Remove(position);

                    if (BoardDB.GetDB().SaveChanges() == 1)
                    {
                        Board.PositionsList.RemoveAt(index);
                    }
                }
                else
                {
                    lblError.Content = "Nie można usunąć";
                }
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string name        = txtName.Text;
                string description = txtDescription.Text;

                long employId     = BoardDB.GetEmployees().ToList().First(employ => employ.ToString() == cbAssignee.Text).employId;
                long openColumnId = Board.GetKeyForValue("Open", Board.Columns).columnId;

                Estimate estimation = Board.GetKeyForValue <Estimate>(cbEstimation.Text, Board.Estimates);
                DateTime endDate    = (DateTime)pickerDateEnd.SelectedDate;

                Task newTask = new Task(name, description, estimation, endDate, openColumnId, employId);
                Board.AddNewTaskToBoard(newTask);

                this.NavigationService.GoBack();
            }
            catch (InvalidOperationException err)
            {
                lblError.Content = $"{err.Message}";
            }
        }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string name = txtName.Text;

                Board.CurrentlySelectedPosition.Name = name;

                if (BoardDB.GetDB().SaveChanges() == 1)
                {
                    CollectionViewSource.GetDefaultView(Board.PositionsList).Refresh();
                    this.NavigationService.GoBack();
                }
                else
                {
                    lblError.Content = "Błąd edycji";
                }
            }
            catch (InvalidOperationException err)
            {
                lblError.Content = err.Message;
            }
        }
        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            int index = ListOfEmployees.SelectedIndex;

            if (index >= 0)
            {
                var employ = Board.EmployAndPositionList[index].employ;

                if (employ.employId != 0)
                {
                    BoardDB.GetEmployees().Remove(employ);

                    if (BoardDB.GetDB().SaveChanges() == 1)
                    {
                        Board.EmployAndPositionList.RemoveAt(index);
                        Board.ClearListsAndRestoreFromDB();
                    }
                }
                else
                {
                    lblError.Content = "Nie można usunąć";
                }
            }
        }
 ///   <summary>
 ///      returns Employees table from DB
 ///      <example>
 ///        <code>
 ///             BoardDB.GetEmployees();
 ///        </code>
 ///      </example>
 ///    </summary>
 public static DbSet <Employ> GetEmployees() => BoardDB.GetDB().Employees;
 ///   <summary>
 ///      returns employ with given id
 ///      <example>
 ///        <code>
 ///             BoardDB.GetEmploy(employId);
 ///        </code>
 ///      </example>
 ///    </summary>
 public static Employ GetEmploy(long employId) => BoardDB.GetEmployees().FirstOrDefault(p => p.employId == employId);
 ///   <summary>
 ///      saves changes in DB
 ///      <example>
 ///        <code>
 ///             BoardDB.SaveChanges();
 ///        </code>
 ///      </example>
 ///    </summary>
 public static int SaveChanges() => BoardDB.GetDB().SaveChanges();
 ///   <summary>
 ///      returns Tasks table from DB
 ///      <example>
 ///        <code>
 ///             BoardDB.GetTasks();
 ///        </code>
 ///      </example>
 ///    </summary>
 public static DbSet <Task> GetTasks() => BoardDB.GetDB().Tasks;
        ///   <summary>
        ///      returns DB
        ///      <example>
        ///        <code>
        ///             BoardDB.GetDB();
        ///        </code>
        ///      </example>
        ///    </summary>
        public static AgileBoardDB GetDB()
        {
            BoardDB.CheckDBConnection();

            return(BoardDB.db);
        }
 ///   <summary>
 ///      returns Positions table from DB
 ///      <example>
 ///        <code>
 ///             BoardDB.GetPositions();
 ///        </code>
 ///      </example>
 ///    </summary>
 public static DbSet <Position> GetPositions() => BoardDB.GetDB().Positions;
 ///   <summary>
 ///      returns Estimates table from DB
 ///      <example>
 ///        <code>
 ///             BoardDB.GetEstimations();
 ///        </code>
 ///      </example>
 ///    </summary>
 public static DbSet <Estimate> GetEstimations() => BoardDB.GetDB().Estimates;
 ///   <summary>
 ///      returns Columns table from DB
 ///      <example>
 ///        <code>
 ///             BoardDB.GetColumns();
 ///        </code>
 ///      </example>
 ///    </summary>
 public static DbSet <Column> GetColumns() => BoardDB.GetDB().Columns;