DepartmentProject/DepartmentPortal/AcademicProgressWindowsDesktop/AcademicProgressWindowDesktopExtension.cs

98 lines
3.6 KiB
C#
Raw Normal View History

using AcademicProgressWindowsDesktop.EntityControls.StudentAcademicProgress;
using AcademicProgressWindowsDesktop.SpecialControls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using ModuleTools.BindingModels;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
using ModuleTools.Interfaces;
using ModuleTools.Models;
using System.Collections.Generic;
namespace AcademicProgressWindowsDesktop
{
public class AcademicProgressWindowDesktopExtension : IWindowDesktopExtension
{
public List<WindowDesktopExtensionControlModel> GetListControlEntityList()
{
var manager = DependencyManager.Instance.Resolve<ISecurityManager>();
if (manager == null)
{
return null;
}
if (!manager.CheckAccess(new SecurityManagerCheckAccessModel(new AccessBindingModel { UserIdForAccess = manager.User },
AccessOperation.Учет_успеваемости, AccessType.View, "Учет успеваемости")))
{
return null;
}
var list = new List<WindowDesktopExtensionControlModel>
{
new WindowDesktopExtensionControlModel { Title = "Учет успеваемости" }
};
List<IControl> _controls = new()
{
new ControlStudentAcademicProgressList()
};
foreach (var cntrl in _controls)
{
if (manager.CheckAccess(new SecurityManagerCheckAccessModel(new AccessBindingModel { UserIdForAccess = manager.User },
cntrl.AccessOperation, AccessType.View, cntrl.Title)))
{
list.Add(new WindowDesktopExtensionControlModel
{
Id = cntrl.ControlId,
Title = cntrl.Title,
Control = cntrl
});
}
}
return list;
}
public List<WindowDesktopExtensionControlModel> GetListControlSpecialList()
{
var manager = DependencyManager.Instance.Resolve<ISecurityManager>();
if (manager == null)
{
return null;
}
if (!manager.CheckAccess(new SecurityManagerCheckAccessModel(new AccessBindingModel { UserIdForAccess = manager.User },
AccessOperation.Учет_успеваемости, AccessType.View, "Учет успеваемости")))
{
return null;
}
var list = new List<WindowDesktopExtensionControlModel>
{
new WindowDesktopExtensionControlModel { Title = "Учет успеваемости" }
};
List<IControl> _controls = new()
{
new ControlStudentGraduate(),
new ControlReportPlanDisciplines(),
new ControlReportAcademicProgress()
};
foreach (var cntrl in _controls)
{
if (manager.CheckAccess(new SecurityManagerCheckAccessModel(new AccessBindingModel { UserIdForAccess = manager.User },
cntrl.AccessOperation, AccessType.View, cntrl.Title)))
{
list.Add(new WindowDesktopExtensionControlModel
{
Id = cntrl.ControlId,
Title = cntrl.Title,
Control = cntrl
});
}
}
return list;
}
}
}