Exemplo n.º 1
0
        public ProjectViewModel(NavigationService navigation)
        {
            this.navigation = navigation;
            columnService   = new ColumnService();

            columnService.LoadColumns(CurrentProject.Instance.Project.Id);

            ProjectTitle   = CurrentProject.Instance.Project.Name;
            ProjectEmail   = CurrentProject.Instance.Project.ProjectEmail;
            ProjectManager = CurrentProject.Instance.Project.ProjectManager;
            Deadline       = CurrentProject.Instance.Project.Deadline;
            Description    = CurrentProject.Instance.Project.Description;

            int columns = 0;
            int count   = 0;

            if (ColumnsOfProject.Instance.Columns != null)
            {
                columns = ColumnsOfProject.Instance.Columns.Count();
                var c = ColumnsOfProject.Instance.Columns;
                c.ToList().ForEach(z => count++);
            }
            CountOfColumns = columns.ToString();
            CountOfTasks   = count.ToString();
            CreatedAt      = "Created at: " + CurrentProject.Instance.Project.CreatedAt.Humanize();

            timer = new System.Timers.Timer(1000);
            timer.Start();
            timer.Elapsed += Timer_Elapsed;
        }
Exemplo n.º 2
0
        public void Drop(IDropInfo dropInfo)
        {
            if (dropInfo.Data is Task)
            {
                Task    sourceItem = dropInfo.Data as Task;
                dynamic targetItem;
                Guid    targetId;

                if (dropInfo.TargetItem is ColumnItemViewModel)
                {
                    targetItem = dropInfo.TargetItem as ColumnItemViewModel;
                    targetId   = targetItem.Column.Id;
                    if (taskService.FindById(sourceItem.Id) != null && columnService.FindById(targetItem.Column.Id) != null)
                    {
                        var colLast = columnService.FindById(sourceItem.Column.Id);
                        var colNew  = columnService.FindById(targetId);
                        taskService.UpdateColumnId(targetId, sourceItem);

                        var log = new TaskLog
                        {
                            ChangedBy = CurrentUser.Instance.User.FullName,
                            TaskId    = sourceItem.Id
                        };

                        log.Message = TaskLogMessages.ColumnChangedMessage(colLast.Title, colNew.Title);
                        taskLogService.CreateAsync(log);

                        columnService.LoadColumns(CurrentProject.Instance.Project.Id);
                        columnService.LoadColumns(CurrentProject.Instance.Project.Id);
                        columnService.LoadColumns(CurrentProject.Instance.Project.Id);
                    }
                }
            }
            else
            {
                ColumnItemViewModel sourceItem = dropInfo.Data as ColumnItemViewModel;
                ColumnItemViewModel targetItem = dropInfo.TargetItem as ColumnItemViewModel;
                if (sourceItem != null && targetItem != null)
                {
                    if (columnService.FindById(sourceItem.Column.Id) != null && columnService.FindById(targetItem.Column.Id) != null)
                    {
                        var sourceIndex = ColumnsOfProject.Instance.Columns.First(x => x.Column.Id == sourceItem.Column.Id).Column.Position;
                        var targetIndex = ColumnsOfProject.Instance.Columns.First(x => x.Column.Id == targetItem.Column.Id).Column.Position;
                        if (sourceIndex != targetIndex)
                        {
                            columnService.UpdateAsync(sourceIndex, targetItem.Column);
                            columnService.UpdateAsync(targetIndex, sourceItem.Column);
                            columnService.LoadColumns(CurrentProject.Instance.Project.Id);
                            columnService.LoadColumns(CurrentProject.Instance.Project.Id);
                            columnService.LoadColumns(CurrentProject.Instance.Project.Id);
                        }
                    }
                }
            }
        }