summaryrefslogtreecommitdiff
path: root/src/Notepad/Presentation/Model/Menu/File/Commands/ISaveCommand.cs
blob: ea7c396ca61ac959c22ea882f66da4bd1021c1f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Notepad.Infrastructure.Core;
using Notepad.Presentation.Core;
using Notepad.Presentation.Presenters.Menu.File;
using Notepad.Tasks;

namespace Notepad.Presentation.Model.Menu.File.Commands {
    public interface ISaveCommand : ICommand {}

    public class SaveCommand : ISaveCommand {
        private readonly IApplicationController controller;
        private readonly IDocumentTasks tasks;

        public SaveCommand(IApplicationController controller, IDocumentTasks tasks) {
            this.controller = controller;
            this.tasks = tasks;
        }

        public void Execute() {
            if (!tasks.HasAPathToSaveToBeenSpecified()) {
                controller.Run<ISaveAsPresenter>();
            }
            else {
                tasks.SaveTheActiveDocument();
            }
        }
    }
}