DepartmentProject/DepartmentPortal/Security/SecurityWindowsDesktop/EntityControls/User/ControlUserList.cs

79 lines
2.4 KiB
C#
Raw Normal View History

using DesktopTools.BaseControls;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using ModuleTools.Enums;
using SecurityBusinessLogic.BindingModels;
using SecurityBusinessLogic.BusinessLogics;
using SecurityBusinessLogic.ViewModels;
using System;
using System.Linq;
using System.Windows.Forms;
2021-04-02 15:53:15 +04:00
namespace SecurityWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для списка пользователей
/// </summary>
public partial class ControlUserList :
GenericControlEntityList<UserGetBindingModel, UserSetBindingModel, UserListViewModel, UserViewModel, UserBusinessLogic>,
IGenericControlEntityList<UserListViewModel, UserViewModel>
{
public ControlUserList() : base()
{
InitializeComponent();
Title = "Пользователи";
ControlId = new Guid("d5596997-d1f5-4e5e-b94b-6bdd6bca3452");
AccessOperation = AccessOperation.Пользователи;
ControlViewEntityElement = new ControlUserElement();
_genericControlViewEntityList = this;
FillSearchPanel();
}
public IControl GetInstanceGenericControl() => new ControlUserList() { ControlId = Guid.NewGuid() };
public ControlViewEntityListConfiguration GetConfigControl() => new()
{
PaginationOn = true,
CountElementsOnPage = 40
};
public UserListViewModel GetDataForControl() => throw new NotImplementedException();
public UserListViewModel GetDataFromParentForControl(Guid id) => throw new NotImplementedException();
public UserListViewModel GetDataWithPageNameForControl(string key) => throw new NotImplementedException();
public UserListViewModel GetDataWithPageNumberForControl(int page, int count)
{
var model = new UserGetBindingModel
{
PageNumber = page,
PageSize = count
};
if (_searchValues != null)
{
var cntrl = _searchValues.FirstOrDefault(x => x.Name == "UserNameForSearch");
if (cntrl != default)
{
model.UserNameForSearch = cntrl.Value.ToString();
}
}
return _businessLogic.GetList(model);
}
private void FillSearchPanel()
{
2021-04-03 11:39:49 +04:00
var control = new BaseControlString("UserNameForSearch", false, false, 0)
{
Location = new System.Drawing.Point(10, 10),
Size = new System.Drawing.Size(400, 23),
Name = "SearchUserName",
TabIndex = 0
};
control.SetTitleWidth(control.SetTitle("Имя пользователя:"));
panelSearchControls.Controls.Add(control);
}
}
}