using System.Threading.Tasks; using Artemis.Core.Models.Profile.Abstract; using Artemis.UI.ViewModels.Dialogs; using FluentValidation; using Stylet; namespace Artemis.UI.Screens.Module.ProfileEditor.Dialogs { public class ProfileElementRenameViewModel : DialogViewModelBase { public ProfileElementRenameViewModel(IModelValidator validator, ProfileElement profileElement) : base(validator) { ElementName = profileElement.Name; } public string ElementName { get; set; } public async Task Accept() { await ValidateAsync(); if (HasErrors) return; Session.Close(ElementName); } public void Cancel() { Session.Close(); } } public class ProfileElementRenameViewModelValidator : AbstractValidator { public ProfileElementRenameViewModelValidator() { RuleFor(m => m.ElementName).NotEmpty().WithMessage("Element name may not be empty"); } } }