Files
Artemis/src/Artemis.UI/Screens/Module/ProfileEditor/Dialogs/ProfileElementRenameViewModel.cs
T
SpoinkyNL 75e932edb1 Added folder/layer renaming
Implemented profile saving
2019-11-24 23:01:11 +01:00

41 lines
1.1 KiB
C#

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<ProfileElementRenameViewModel> 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<ProfileElementRenameViewModel>
{
public ProfileElementRenameViewModelValidator()
{
RuleFor(m => m.ElementName).NotEmpty().WithMessage("Element name may not be empty");
}
}
}