Beispiel #1
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);
                        }
                    }
                }
            }
        }
Beispiel #2
0
 public ColumnItemViewModel()
 {
     Column = new Column();
     Task   = new Task();
 }