Files
LeanderShiftPlannerV2/LeanderShiftPlannerV2/View/PersonView/PersonCreator.axaml.cs
2025-07-08 10:32:34 +02:00

38 lines
1.1 KiB
C#

using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using LeanderShiftPlannerV2.Service;
using LeanderShiftPlannerV2.Util;
namespace LeanderShiftPlannerV2.View.PersonView;
public partial class PersonCreator : Window
{
private readonly AppService _appService;
public PersonCreator(AppService appService)
{
InitializeComponent();
this._appService = appService;
}
private void ButtonCreatePerson_Click(object sender, RoutedEventArgs e)
{
if (TextBoxName.Text != "" && TextBoxHours.Text != "" && TextBoxSurname.Text != ""
&& TextBoxName.Text != null && TextBoxHours.Text != null && TextBoxSurname.Text != null)
{
_appService.PersonService.AddNewPerson(TextBoxName.Text, TextBoxSurname.Text, TextBoxHours.Text);
this.Close();
}
else
{
ViewService.ShowNoInputError(this);
}
}
private void TextBoxHours_PreviewTextInput(object sender, TextInputEventArgs e)
{
if (e.Text != null) e.Handled = ViewUtil.CheckNumericText(e.Text);
}
}