92 lines
3.1 KiB
C#
92 lines
3.1 KiB
C#
using DepartmentBusinessLogic.BindingModels;
|
||
using DepartmentBusinessLogic.BusinessLogics;
|
||
using DepartmentBusinessLogic.ViewModels;
|
||
using DesktopTools.BaseControls;
|
||
using DesktopTools.Controls;
|
||
using DesktopTools.Interfaces;
|
||
using DesktopTools.Models;
|
||
using ModuleTools.BusinessLogics;
|
||
using ModuleTools.Enums;
|
||
using System;
|
||
using System.Linq;
|
||
|
||
namespace DepartmentWindowsDesktop.EntityControls
|
||
{
|
||
public partial class ControlDisciplineList :
|
||
GenericControlEntityList<DisciplineGetBindingModel, DisciplineSetBindingModel, DisciplineListViewModel, DisciplineViewModel, DisciplineBusinessLogic>,
|
||
IGenericControlEntityList<DisciplineListViewModel, DisciplineViewModel>
|
||
{
|
||
private readonly DisciplineBlockBusinessLogic _disciplineBlockBusinessLogic;
|
||
|
||
public ControlDisciplineList()
|
||
{
|
||
InitializeComponent();
|
||
_disciplineBlockBusinessLogic = DependencyManager.Instance.Resolve<DisciplineBlockBusinessLogic>();
|
||
Title = "Дисциплины";
|
||
ControlId = new Guid("1731f50b-b20b-44c4-aa56-b335764fae7a");
|
||
AccessOperation = AccessOperation.Дисциплины;
|
||
ControlViewEntityElement = new ControlDisciplineElement();
|
||
_genericControlViewEntityList = this;
|
||
FillSearchPanel();
|
||
}
|
||
|
||
public IControl GetInstanceGenericControl() => new ControlDisciplineList() { ControlId = Guid.NewGuid() };
|
||
|
||
public ControlViewEntityListConfiguration GetConfigControl() => new()
|
||
{
|
||
PaginationOn = true,
|
||
PageNamesForPagination = _disciplineBlockBusinessLogic.GetList(new DisciplineBlockGetBindingModel())?.List?.Select(x =>
|
||
new PageNamesForPaginationModel
|
||
{
|
||
Key = x.Id.ToString(),
|
||
Value = x.Title
|
||
})?.ToList(),
|
||
ParentPropertyName = "DisciplineBlockId"
|
||
};
|
||
|
||
public DisciplineListViewModel GetDataForControl()
|
||
{
|
||
var model = new DisciplineGetBindingModel();
|
||
if (_searchValues != null)
|
||
{
|
||
var cntrl = _searchValues.FirstOrDefault(x => x.Name == "UserNameForSearch");
|
||
if (cntrl != default)
|
||
{
|
||
model.DisciplineName = cntrl.Value.ToString();
|
||
}
|
||
}
|
||
return _businessLogic.GetList(model);
|
||
}
|
||
|
||
public DisciplineListViewModel GetDataFromParentForControl(Guid id)
|
||
{
|
||
var model = new DisciplineGetBindingModel { DisciplineBlockId = id };
|
||
if (_searchValues != null)
|
||
{
|
||
var cntrl = _searchValues.FirstOrDefault(x => x.Name == "UserNameForSearch");
|
||
if (cntrl != default)
|
||
{
|
||
model.DisciplineName = cntrl.Value.ToString();
|
||
}
|
||
}
|
||
return _businessLogic.GetList(model);
|
||
}
|
||
|
||
public DisciplineListViewModel GetDataWithPageNameForControl(string key) => throw new NotImplementedException();
|
||
|
||
public DisciplineListViewModel GetDataWithPageNumberForControl(int page, int count) => throw new NotImplementedException();
|
||
|
||
private void FillSearchPanel()
|
||
{
|
||
var control = new BaseControlString("DisciplineNameForSearch", false, false, 0)
|
||
{
|
||
Location = new System.Drawing.Point(10, 10),
|
||
Size = new System.Drawing.Size(400, 23),
|
||
Name = "SearchDisciplineName",
|
||
TabIndex = 0
|
||
};
|
||
control.SetTitleWidth(control.SetTitle("Название:"));
|
||
panelSearchControls.Controls.Add(control);
|
||
}
|
||
}
|
||
} |