2024-11-26 20:02:29 +04:00
|
|
|
|
using EmployeeManager.Model;
|
|
|
|
|
using EmployeeManager.View.PhysicalPerson;
|
|
|
|
|
using System;
|
2024-11-26 14:12:47 +04:00
|
|
|
|
using System.Collections.Generic;
|
2024-11-26 20:02:29 +04:00
|
|
|
|
using System.ComponentModel;
|
2024-11-26 14:12:47 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-11-26 20:02:29 +04:00
|
|
|
|
using System.Windows;
|
2024-11-26 14:12:47 +04:00
|
|
|
|
|
|
|
|
|
namespace EmployeeManager.ViewModel
|
|
|
|
|
{
|
2024-11-26 20:02:29 +04:00
|
|
|
|
public class DataManageViewModel : INotifyPropertyChanged
|
2024-11-26 14:12:47 +04:00
|
|
|
|
{
|
2024-11-26 21:01:01 +04:00
|
|
|
|
private readonly IPhysicalPersonService _physicalPersonService;
|
|
|
|
|
|
|
|
|
|
public DataManageViewModel(IPhysicalPersonService physicalPersonService)
|
|
|
|
|
{
|
|
|
|
|
_physicalPersonService = physicalPersonService;
|
|
|
|
|
AllPhysicalPeoples = _physicalPersonService.GetAllPhysicalPersons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<PhysicalPerson> allPhysicalPeoples;
|
2024-11-26 20:02:29 +04:00
|
|
|
|
public List<PhysicalPerson> AllPhysicalPeoples
|
|
|
|
|
{
|
2024-11-26 21:01:01 +04:00
|
|
|
|
get => allPhysicalPeoples;
|
2024-11-26 20:02:29 +04:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
allPhysicalPeoples = value;
|
2024-11-26 21:01:01 +04:00
|
|
|
|
NotifyPropertyChanged(nameof(AllPhysicalPeoples));
|
2024-11-26 20:02:29 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-26 21:01:01 +04:00
|
|
|
|
public string NamePhysicalPersons { get; set; }
|
|
|
|
|
public string SurnamePhysicalPersons { get; set; }
|
|
|
|
|
public string PatronomicPhysicalPersons { get; set; }
|
2024-11-26 20:35:57 +04:00
|
|
|
|
public DateTime Birthday { get; set; }
|
2024-11-26 21:01:01 +04:00
|
|
|
|
public string Gender { get; set; }
|
|
|
|
|
public string Address { get; set; }
|
|
|
|
|
public string Telephone { get; set; }
|
2024-11-26 20:35:57 +04:00
|
|
|
|
|
2024-11-26 21:01:01 +04:00
|
|
|
|
public RelayCommand AddNewPhysicalPersonCommand => new RelayCommand(obj =>
|
2024-11-26 20:02:29 +04:00
|
|
|
|
{
|
2024-11-26 21:01:01 +04:00
|
|
|
|
var newPerson = new PhysicalPersonDto
|
2024-11-26 20:02:29 +04:00
|
|
|
|
{
|
2024-11-26 21:01:01 +04:00
|
|
|
|
Name = NamePhysicalPersons,
|
|
|
|
|
Surname = SurnamePhysicalPersons,
|
|
|
|
|
Patronomic = PatronomicPhysicalPersons,
|
|
|
|
|
Birthday = Birthday,
|
|
|
|
|
Gender = Gender,
|
|
|
|
|
Address = Address,
|
|
|
|
|
Telephone = Telephone
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
string result = _physicalPersonService.CreatePhysicalPerson(newPerson);
|
|
|
|
|
// Обновить список
|
|
|
|
|
AllPhysicalPeoples = _physicalPersonService.GetAllPhysicalPersons();
|
|
|
|
|
});
|
2024-11-26 20:02:29 +04:00
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
2024-11-26 21:01:01 +04:00
|
|
|
|
private void NotifyPropertyChanged(string propertyName) =>
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
2024-11-26 14:12:47 +04:00
|
|
|
|
}
|
|
|
|
|
}
|