Exemplo n.º 1
0
        protected IssueModifyViewModel(string username, string repository)
        {
            var alertDialogService = Locator.Current.GetService <IAlertDialogService>();

            Username   = username;
            Repository = repository;
            Kind       = "bug";
            Priority   = "major";

            Milestones = new IssueMilestonesViewModel(username, repository);
            Versions   = new IssueVersionsViewModel(username, repository);
            Components = new IssueComponentsViewModel(username, repository);
            Assignee   = new IssueAssigneeViewModel(username, repository);

            SaveCommand = ReactiveCommand.CreateFromTask(
                t => Save(),
                this.WhenAnyValue(x => x.IssueTitle).Select(y => !string.IsNullOrEmpty(y)));

            SaveCommand.BindCommand(DismissCommand);

            DiscardCommand = ReactiveCommand.CreateFromTask(async t =>
            {
                if (Content?.Length > 0 || IssueTitle?.Length > 0)
                {
                    var result = await alertDialogService.PromptYesNo(
                        "Discard Changes", "Are you sure you want to discard your changes?");
                    if (!result)
                    {
                        return;
                    }
                }

                DismissCommand.ExecuteNow();
            });
        }