using System.Threading.Tasks; using Artemis.UI.Shared.Services; using FluentValidation; using Stylet; namespace Artemis.UI.Screens.ProfileEditor.Dialogs { public class ProfileCreateViewModel : DialogViewModelBase { private string _profileName; public ProfileCreateViewModel(IModelValidator validator) : base(validator) { } public string ProfileName { get => _profileName; set => SetAndNotify(ref _profileName, value); } public async Task Accept() { await ValidateAsync(); if (HasErrors) return; Session.Close(ProfileName); } } public class ProfileCreateViewModelValidator : AbstractValidator { public ProfileCreateViewModelValidator() { RuleFor(m => m.ProfileName).NotEmpty().WithMessage("Profile name may not be empty"); } } }