Example #1
0
        private void RemoveSelectedStory()
        {
            if (SelectedStory == null)
            {
                return;
            }

            _menuBasedShellViewModel.IsLoadingData = true;

            new Task(() =>
            {
                try
                {
                    _storiesDataModel.Remove(SelectedStory.Story);

                    ComponentsContainer.Get <Dispatcher>().Invoke(
                        delegate
                    {
                        AllUserStories.Remove(SelectedStory);
                    });

                    HideDialog?.Invoke(this, null);
                }
                catch (Exception ex)
                {
                    ShowMessage($"User story doesn't removed: technical issues encountered.");
                    _logger.Fatal(ex);
                }

                _menuBasedShellViewModel.IsLoadingData = false;
            }).Start();
        }
Example #2
0
 private void ShowMessage(string text)
 {
     MessageBoxViewModel            = new MessageBoxViewModel();
     MessageBoxViewModel.Text       = text;
     MessageBoxViewModel.Confirmed += delegate { HideDialog?.Invoke(this, null); };
     SetDialog?.Invoke(this, MessageBoxViewModel);
 }
Example #3
0
        private void InitializeCommands()
        {
            _requestUserStoryCreation = new Command(
                new Action(
                    delegate
            {
                StoryDialogViewModel = new StoryDialogViewModel();
                StoryDialogViewModel.IsStatusEditable = false;
                StoryDialogViewModel.Status           = _storyStatusesDataModel.GetStatusText(StoryStatus.WaitingForExecutor);
                StoryDialogViewModel.ConfirmSelected += CreateStoryFromDialog;
                StoryDialogViewModel.CancelSelected  +=
                    delegate
                {
                    HideDialog?.Invoke(this, null);
                };
                SetDialog?.Invoke(this, StoryDialogViewModel);
            }),
                null);

            _finishCommand = new Command(
                new Action(
                    delegate
            {
                ConfirmationDialogViewModel                  = new ConfirmationDialogViewModel();
                ConfirmationDialogViewModel.Text             = "Do you really want to finish the sprint now?";
                ConfirmationDialogViewModel.ConfirmSelected += FinishCurrentSprint;
                ConfirmationDialogViewModel.CancelSelected  +=
                    delegate
                {
                    HideDialog?.Invoke(this, null);
                };
                SetDialog?.Invoke(this, ConfirmationDialogViewModel);
            }),
                null);

            _requestStoryEditing = new Command(
                parameterizedAction :
                delegate(object param)
            {
                StoryDialogViewModel = new StoryDialogViewModel();
                StoryDialogViewModel.IsStatusEditable = true;
                StoryDialogViewModel.ConfirmSelected += EditSelectedStory;
                StoryDialogViewModel.CancelSelected  += delegate { HideDialog?.Invoke(this, null); };
                FillStoryDialog(param);
                SetDialog?.Invoke(this, StoryDialogViewModel);
            },
                canExecute: null);

            _requestStoryRemoving = new Command(
                parameterizedAction :
                delegate(object param)
            {
                ConfirmationDialogViewModel                  = new ConfirmationDialogViewModel();
                ConfirmationDialogViewModel.Text             = "Are you sure you want to delete the user story?";
                ConfirmationDialogViewModel.ConfirmSelected += RemoveSelectedStory;
                ConfirmationDialogViewModel.CancelSelected  += delegate { HideDialog?.Invoke(this, null); };
                SetDialog?.Invoke(this, ConfirmationDialogViewModel);
            },
                canExecute: null);
        }
Example #4
0
        private void InitializeFields()
        {
            Project currentProject = _menuBasedShellViewModel.CurrentProject;

            if (currentProject == null)
            {
                MessageBoxViewModel            = new MessageBoxViewModel();
                MessageBoxViewModel.Text       = "Select project!";
                MessageBoxViewModel.Confirmed += delegate
                {
                    _menuBasedShellViewModel.SetCurrentViewModel(typeof(Projects.ProjectsViewModel));
                };
                SetDialog?.Invoke(this, MessageBoxViewModel);
                return;
            }

            Data.Entities.Sprint currentSprint = _sprintsDataModel.GetSprintByProjectId(_menuBasedShellViewModel.CurrentProject.Id);

            if (currentSprint == null)
            {
                SprintDialogViewModel = new SprintDialogViewModel();
                SprintDialogViewModel.ConfirmSelected += delegate
                {
                    CreateSprintFromDialog(); // Here sets value of '_currentSprint'.
                    HideDialog?.Invoke(this, null);
                };
                SprintDialogViewModel.CancelSelected += delegate { /*HideDialog?.Invoke(this, null);*/ };
                SetDialog?.Invoke(this, SprintDialogViewModel);
            }
            else
            {
                if (_currentSprint != null)
                {
                    if (!_currentSprint.Equals(currentSprint))
                    {
                        _currentSprint = currentSprint;
                        Backlog          currentSprintBacklog = ComponentsContainer.Get <IBacklogsDataModel>().GetBacklogById(currentSprint.BacklogId);
                        List <StoryItem> items = ConvertToStoryItems(currentSprintBacklog.Stories);
                        AllUserStories = new ObservableCollection <StoryItem>(items);
                        InitializeSprintDependentFields();
                    }
                }
                else
                {
                    _currentSprint = currentSprint;
                    Backlog          currentSprintBacklog = ComponentsContainer.Get <IBacklogsDataModel>().GetBacklogById(currentSprint.BacklogId);
                    List <StoryItem> items = ConvertToStoryItems(currentSprintBacklog.Stories);
                    AllUserStories = new ObservableCollection <StoryItem>(items);
                    InitializeSprintDependentFields();
                }
            }
        }
Example #5
0
        private void SetUserAsExecutor(StoryItem obj)
        {
            if (SelectedStory == null)
            {
                return;
            }

            _menuBasedShellViewModel.IsLoadingData = true;

            new Task(() =>
            {
                try
                {
                    Story story = SelectedStory.Story;
                    SelectedStory.ExecutorId = _menuBasedShellViewModel.CurrentUser.Id;
                    SetStatus(ref story, StoryStatus.InProgress);

                    _logger.Debug($"Started editing story with id '{SelectedStory.Id}'.");

                    _storiesDataModel.Update(story);

                    SelectedStory.Story = story;

                    ComponentsContainer.Get <Dispatcher>().Invoke(
                        delegate
                    {
                        OnPropertyChanged("WaitingForExecutorStories");
                        OnPropertyChanged("InProgressStories");
                        OnPropertyChanged("CompletedStories");

                        //AllUserStories.Remove(SelectedStory); // It will throw exception in view.
                        //AllUserStories.Add(SelectedStory);
                    });
                }
                catch (Exception ex)
                {
                    ShowMessage($"User story doesn't edited: technical issues encountered.");
                    _logger.Fatal(ex);
                }

                _menuBasedShellViewModel.IsLoadingData = false;
                HideDialog?.Invoke(this, null);
            }).Start();
        }
Example #6
0
        private void EditSelectedStory()
        {
            if (StoryDialogViewModel == null)
            {
                return;
            }

            if (!StoryDialogViewModel.CanExecuteConfirmCommand(null))
            {
                return;
            }

            if (SelectedStory == null)
            {
                return;
            }

            _menuBasedShellViewModel.IsLoadingData = true;

            new Task(() =>
            {
                try
                {
                    StoryItem newStoryItem = SelectedStory.Clone() as StoryItem;

                    newStoryItem.Name            = StoryDialogViewModel.Name;
                    newStoryItem.Importance      = StoryDialogViewModel.Importance;
                    newStoryItem.InitialEstimate = StoryDialogViewModel.InitialEstimate;
                    newStoryItem.Status          = StoryDialogViewModel.Status;
                    newStoryItem.HowToDemo       = StoryDialogViewModel.HowToDemo;
                    newStoryItem.Notes           = StoryDialogViewModel.Notes;

                    string previousStatus = SelectedStory.Status;
                    string newStatus      = newStoryItem.Status;

                    if (previousStatus != newStatus)                                                                 // status was changed
                    {
                        if (previousStatus == _storyStatusesDataModel.GetStatusText(StoryStatus.WaitingForExecutor)) // it was "WaitingForExecutor" status
                        {
                            newStoryItem.ExecutorId = _menuBasedShellViewModel.CurrentUser.Id;
                        }
                        else if (previousStatus == _storyStatusesDataModel.GetStatusText(StoryStatus.InProgress)) // it was "InProgress" status
                        {
                            if (newStoryItem.ExecutorId != _menuBasedShellViewModel.CurrentUser.Id)
                            {
                                StoryDialogViewModel.ErrorMessage      = "You can't change the task executing by another user.";
                                StoryDialogViewModel.ShowErrorMessage  = true;
                                _menuBasedShellViewModel.IsLoadingData = false;
                                return;
                            }
                            else
                            {
                                newStoryItem.ExecutorId = (newStatus == _storyStatusesDataModel.GetStatusText(StoryStatus.WaitingForExecutor)) ? 0 : _menuBasedShellViewModel.CurrentUser.Id;
                            }
                        }
                        else if (previousStatus == _storyStatusesDataModel.GetStatusText(StoryStatus.Completed)) // it was "Completed" status
                        {
                            if (newStoryItem.ExecutorId != _menuBasedShellViewModel.CurrentUser.Id)
                            {
                                StoryDialogViewModel.ErrorMessage      = "You can't change the task executed by another user.";
                                StoryDialogViewModel.ShowErrorMessage  = true;
                                _menuBasedShellViewModel.IsLoadingData = false;
                                return;
                            }
                            else
                            {
                                newStoryItem.ExecutorId = (newStatus == _storyStatusesDataModel.GetStatusText(StoryStatus.WaitingForExecutor)) ? 0 : _menuBasedShellViewModel.CurrentUser.Id;
                            }
                        }
                    }

                    if (SelectedStory.Equals(newStoryItem))
                    {
                        StoryDialogViewModel.ErrorMessage      = "Story data is not changed";
                        StoryDialogViewModel.ShowErrorMessage  = true;
                        _menuBasedShellViewModel.IsLoadingData = false;
                        return;
                    }

                    List <StoryItem> storyItemsWithTheSameName = AllUserStories.Where(si => si.Name == newStoryItem.Name).ToList();

                    if (storyItemsWithTheSameName.Count > 0)
                    {
                        if (storyItemsWithTheSameName.First().Id != newStoryItem.Id)
                        {
                            StoryDialogViewModel.ErrorMessage      = $"Story with name '{newStoryItem.Name}' already exists.";
                            StoryDialogViewModel.ShowErrorMessage  = true;
                            _menuBasedShellViewModel.IsLoadingData = false;
                            return;
                        }
                    }

                    _logger.Debug($"Started editing story with id '{SelectedStory.Id}'.");

                    _storiesDataModel.Update(newStoryItem.Story);

                    StoryItem item = AllUserStories.FirstOrDefault(s => s.Id == newStoryItem.Id);

                    if (item != null)
                    {
                        ComponentsContainer.Get <Dispatcher>().Invoke(
                            delegate
                        {
                            AllUserStories.Remove(item);
                            newStoryItem.StoryUpdated += OnStoryItemUpdated;
                            AllUserStories.Add(newStoryItem);
                        });
                    }

                    HideDialog?.Invoke(this, null);
                }
                catch (Exception ex)
                {
                    ShowMessage($"User story doesn't edited: technical issues encountered.");
                    _logger.Fatal(ex);
                }

                _menuBasedShellViewModel.IsLoadingData = false;
            }).Start();
        }