Beispiel #1
0
        internal List(EF.IUnitOfWork unitOfWork, OpenFormEvents openFormEvents, RefreshDataGridEvents refreshDataGrid)
        {
            InitializeComponent();

            _unitOfWork = unitOfWork;

            _openFormEvents  = openFormEvents;
            _refreshDataGrid = refreshDataGrid;

            _refreshDataGrid.RefreshDataGrid += _refreshDataGrid_RefreshDataGrid;

            SetItemSourceDataGrid();
        }
Beispiel #2
0
        internal Object(EF.IUnitOfWork unitOfWork, OpenFormEvents openFormEvents, RefreshDataGridEvents refreshDataGrid, int?id = null)
        {
            InitializeComponent();

            _unitOfWork = unitOfWork;
            _structures = new List <Models.BaseStructures>();

            _openFormEvents  = openFormEvents;
            _refreshDataGrid = refreshDataGrid;

            var _repoBase       = _unitOfWork.GetRepository <Models.Base>();
            var _repoStructures = _unitOfWork.GetRepository <Models.BaseStructures>();

            if (id is int _id)
            {
                _ref = _repoBase.GetFirstOrDefault(f => f.Code == _id);
                _id  = _ref.Code;

                ICollection <Models.BaseStructures> structures = _repoStructures.GetList(f => f.Base.Code == _ref.Code);

                _structures = _ref.Structures;

                DataGridBaseStructures.ItemsSource = _structures;

                Title += $" {_ref.Name}";
            }
            else
            {
                _ref   = new Models.Base();
                Title += " (новый)";
            }

            SetFormSettings();

            DataContext = _ref;
            _unitOfWork = unitOfWork;
        }